JSON to YAML, YAML to JSON
Convert in both directions as you type. Multi-document files become a JSON array, errors get a line number, and YAML 1.2 typing rules are applied — quoted values stay strings.
Runs entirely in your browser — your JSON is never uploaded.
Both directions run here in the tab. YAML comments are not carried over — JSON has no place to put them — and YAML anchors or multi-document files are read, not written.
How to convert between JSON and YAML
- Pick a direction JSON → YAML turns a JSON document into indented YAML. YAML → JSON does the reverse and pretty-prints the result.
- Paste into the left panel Conversion happens as you type; there is no run button and no upload. Load example shows a deployment-style config in whichever format the direction expects.
- Choose the indentation Two spaces or four. The setting applies to the nesting levels of the YAML, or to the pretty-printed JSON on the way back.
- Use Swap to check the round trip After converting, Swap moves the output into the input and flips the direction. A config that survives JSON → YAML → JSON unchanged is safe to ship.
What actually changes between the two formats
JSON and YAML 1.2 describe the same data model: maps, sequences, strings, numbers, booleans and null. The formats differ only in how those values are written down, so a converter has exactly three jobs — rewrite the syntax, keep every value's type honest, and tell you loudly when it cannot.
- Structure moves from braces and brackets to indentation. Two spaces per level is the convention, four is legal, tabs are not.
- Quotes become optional around most keys and values — but only most. Strings that look like numbers, booleans or null must stay quoted, which is where
"8080"and"true"come from. - Comments exist in YAML and not in JSON, so every
# remarkis lost on the way over. Plan for it: keep a commented copy, or move the remark into adescriptionkey. - Multi-document streams (
---separated files) have no single-document JSON equivalent, so they arrive as one JSON array.
The typing traps that survive conversion
The data model is shared, but the readers are not identical. Three cases come up again and again in real config files:
- Version strings.
version: 1.20is the number 1.2 once the trailing zero is parsed away, andversion: 1.10becomes 1.1. Quote every version, tag and build number. - Yes and no. YAML 1.1 readers parse them as booleans; YAML 1.2 does not. A file that flips behaviour between two environments is usually meeting two different YAML versions.
- Leading zeros.
zip: 02134is the number 2134 in YAML 1.1 readers and the string 02134 in YAML 1.2. The same digits in JSON are always a string if quoted and a syntax question if not.
This tool applies YAML 1.2 rules on the way in, and the JSON → YAML direction re-quotes anything that a YAML reader would otherwise misread, so round trips keep both the value and the type.
Config typing is not the only place JSON quietly reshapes values — numbers in API payloads have their own set of traps, covered in the guide to precision loss in JSON numbers.