Convert JSON to YAML

Get clean block-style YAML from JSON. Strings that YAML would read as booleans, numbers or dates stay quoted, and the result is parsed back to prove it matches.

JSON input

YAML output

Converting…

Quotes only where they matter

Most strings come out plain. Strings that a YAML parser would read differently — "true", "null", "1e3", and, with the YAML 1.1 guard on, "no", "on" and dates — keep their quotes. Multi-line strings become literal block scalars.

JSON.parse silently keeps the last of two duplicate keys. FormatYAML keeps both and flags them so you can decide.

Questions

Is the YAML output verified?
Yes. The YAML is parsed back and compared to the JSON input as a representation graph, including exact big integers.
Can I choose the indentation?
Yes, 2 or 4 spaces (or any value from 1 to 8).

Other tools