JSON to YAML
Convert JSON to idiomatic YAML with the quoting handled correctly.
About this converter
Emits the YAML humans write: two-space indents, dash lists, empty collections as {} and [], and โ the part that actually matters โ correct quoting of every string that YAML would otherwise misread.
The Norway problem, and other quoting landmines
YAML's convenience is also its trap: unquoted scalars are interpreted, and interpretation has famous casualties. "NO" โ Norway's country code โ reads as boolean false in YAML 1.1 parsers (the "Norway problem", by name, in every YAML criticism ever written). Version "1.10" becomes the float 1.1. "08:30" can parse as sexagesimal arithmetic. A string starting with * or & collides with alias syntax. Hand-converters hit these landmines one production incident at a time; this emitter quotes exactly the strings that need protection โ lookalike booleans and numbers, colons and hash marks, leading special characters, whitespace edges โ and leaves everything else clean and unquoted, which is what "idiomatic" means. Output drops straight into docker-compose, GitHub Actions and Kubernetes files. Technically JSON already IS valid YAML, but pasting braces into a YAML file earns code-review comments โ this writes the real dialect. Verify any conversion by round-tripping through the reverse tool; the pair agree by design. The JSON formatter tidies input first.
Frequently asked questions
What is the Norway problem?
In YAML 1.1, unquoted 'no' parses as boolean false โ infamously turning Norway's country code into false in config files. This emitter quotes 'no', 'yes', 'on', 'off' and friends automatically.
Why are some strings quoted and others not?
Only strings YAML would misread get quotes: things that look like numbers or booleans, version strings, values with colons or leading special characters. Everything else stays clean โ that's idiomatic YAML.
Isn't JSON already valid YAML?
Technically yes (YAML is a superset), but nobody wants JSON braces in their YAML file. This emits the block style humans read and review tools expect.
How do I verify a conversion?
Round-trip it: convert back with the YAML-to-JSON tool and diff against your original. The two tools share conventions precisely so that check works.