JSON to YAML Converter with Indent and Quoting Control

Convert JSON to YAML with indent, line width, quoting and key sorting options. Safe quoting keeps yes, no and numeric strings as text. In your browser.

Runs in your browser. Nothing is uploaded.

Converters

JSON to YAML

JSON

Max 50MB each

Files are read in your browser and never uploaded. Up to 50 MB, UTF-8 text.

Anchors and aliases (&a, *a) are never written: repeated data is repeated in full.

Result

Paste JSON on the left, or load the sample. YAML appears here as you type.

Example

Input
{"name":"api","replicas":3,"country":"no","ports":[80,443],"env":{"LOG_LEVEL":"info"}}
Result
name: api
replicas: 3
country: 'no'
ports:
  - 80
  - 443
env:
  LOG_LEVEL: info

What the converter does

YAML is a superset of JSON in spirit, so every JSON document has a YAML equivalent. Paste JSON, drop a file, or load the sample and the YAML is written as you type using the js-yaml dumper. Objects become mappings, arrays become sequences, and the options only change how the result looks: indent width of 2, 3, 4 or 6 spaces, the column at which long text is folded onto the next line, and whether to sort keys alphabetically at every level.

You can write list items flush with their key, which is the style used in most Kubernetes manifests and Helm charts, or indented underneath it, which is the default elsewhere. A top-level array can optionally be written as several YAML documents separated by ---, one per item, which is handy for turning a list of Kubernetes objects into a multi-document file for kubectl apply.

Quoting and the Norway problem

The tricky part of writing YAML is deciding which strings need quotes. Under YAML 1.1 rules, the plain words yes, no, on, off, y and n are booleans, so the two-letter country code NO written without quotes is parsed as false by many tools. Strings that look like numbers (123), dates (2001-01-01), null or an empty value change type the same way. This converter quotes any string that could be misread, so the data you get back is the data you put in.

You choose the quote character used when quotes are needed, single or double, or you can quote every string for maximum predictability. Multi-line strings are written as block scalars with a | and the right chomping indicator, and keys that need quoting, such as n, are quoted as well. Anchors and aliases are never written: JSON has no shared references, so repeated data is simply repeated in full.

Limits and tips

JSON integers beyond 2^53 are kept digit for digit as plain YAML integers in browsers that expose the original number text, instead of being rounded. Comments cannot be produced because JSON has none, and key order follows the input unless you sort. Duplicate keys in JSON are collapsed by the JSON parser before conversion, with the last value winning, so check the source if that matters.

If a downstream tool is strict, remember that YAML versions differ. Values written here are safe under both the 1.1 and 1.2 rules because ambiguous strings are quoted. Use the YAML to JSON tool to check the round trip: converting the result back should return your original data. Inputs over about a megabyte are processed in a background worker, and everything stays in your browser.

Frequently asked questions

Why did the converter put quotes around "no" or "yes"?

In YAML 1.1 those words are booleans. Quoting keeps them as strings in every parser. The same applies to strings that look like numbers, dates or null.

How do I get the Kubernetes list style?

Turn on "Flush list items" so a dash starts at the same indent as its key, and use 2 spaces of indent.

Can it write several YAML documents?

Yes. With "One document per array item" a top-level JSON array becomes documents separated by ---.

Does it keep large numbers exact?

Integers beyond 2^53 are written with all their digits in browsers that expose the original number text. Other browsers round them in the JSON parser and the tool warns you.

Is the JSON sent to a server?

No. The conversion runs entirely in your browser.

Related tools