JSON to YAML Converter

Paste a JSON file and get the same settings back as YAML, held together by indents instead of braces.

FluffyShield Protected workspace
FluffyShield

Isolated workspace: other page scripts can't read your files. How FluffyShield works

Free · No upload · No sign-up · No usage quotas

Will every program read your YAML the way you wrote it?

Yes. The converter quotes the words an older YAML reader would misread, such as the country code NO.

From JSON to YAML
  1. Check the JSON is strict and has no setting name twice
  2. Write each setting on a line of its own, lists as dashes
  3. Quote a value where YAML 1.2 or the older 1.1 would misread it

What it does

Same order

The settings come out in the order the JSON has them. Nothing is sorted.

Notes keep their lines

A value with a line break in it becomes a block that starts |-, YAML's mark for "these lines are one value", with one line of the note per line of YAML.

Empty stays empty

null is written as null, which YAML reads as no value too.

Limits Strict JSON only: a comma after the last item, or a comment, stops it at that spot.

A bakery's shipping settings, moved to YAML

Rye bread from a small bakery ships to Denmark, Norway and Sweden, and the bakery's online shop has an admin page that exports its shipping settings as a JSON file: the time of day after which orders wait for the next van, the countries it ships to, and which version of the settings this is. The new site you're moving to keeps all its settings in YAML, a format that drops JSON's braces and most of its quotes and uses indents instead.

The conversion looks clean, and the converter has already been careful: version came out in quotes, because left bare, 1.10 would be read as the number 1.1. It also quoted NO and the cutoff 12:30, which an older YAML reader would misread. The other country codes came out bare.

Two sets of rules for a bare word

YAML guesses what a bare value is from its shape, and the guessing rules changed between versions. Under YAML 1.1, y, yes, on, n, no and off, in their capital forms too, all mean true or false. YAML 1.1 also reads numbers in base 60, the way a clock counts, so 12:30 is twelve sixties and thirty.

YAML 1.2 dropped both. Its rules know only true and false, in three spellings each, and whole numbers in base 10, 8 or 16. This converter writes YAML 1.2 and quotes the words that differ between the two, so every value comes out as it went in under either. Left bare, a YAML 1.1 reader would see something else:

Written1.2 reads1.1 reads- NO"NO"false12:30"12:30"750"1.10""1.10""1.10"

Two sets of rules

Left bare, Norway would drop out of the shipping list under the older rules and the cutoff would become 750. The converter quotes both, so they read as text either way. How we checked

Two lines out of three change, and neither change looks like an error. The shop would stop shipping to Norway, and its cutoff would be a plain number with no clock in it. Quotes settle it: a value in quotes is text under both sets of rules.

Converting the settings, then adding the quotes

  1. Paste the exported settings into the JSON box.

  2. Find NO and 12:30 in the YAML box, which sits behind the Result tab on a phone. Both are in double quotes.

    The top of the YAML box: orderCutoff "12:30" in quotes, then shipsTo with DK, "NO" in quotes, and SE.
    The top of the YAML box: orderCutoff "12:30" in quotes, then shipsTo with DK, "NO" in quotes, and SE.
  3. Press Copy.

  4. The converter has already put double quotes around NO and 12:30, so you can save the file as it is.

With "NO" and "12:30" quoted, both readers agree. The YAML 1.1 reader keeps them as text, and this site's YAML to JSON still gives back the JSON you started with. The result line tells you when quotes were added.

You want to see that the quoted YAML still holds your settings

YAML to JSON Converter

Paste the YAML there, quotes and all. If a value comes back different from the export, put that value in quotes too.

You've edited the YAML by hand and want its indents evened out

JSON formatter, with YAML chosen

Choose YAML under Language and Format under Do. The quotes stay where they are.

Search FluffyBench