How to Convert JSON to YAML (and Back) Online
JSON and YAML describe the same data model — objects, arrays, strings, numbers, booleans, and null — so converting between them is lossless in theory. In practice a few details trip people up.
The mental model
Every JSON document is data that YAML can represent, and almost every YAML document maps cleanly back to JSON. The conversion is mostly syntax: JSON braces become YAML indentation, mandatory quotes become optional, and YAML comments are dropped when converting to JSON.
JSON to YAML
Given this JSON:
{
"name": "my-app",
"port": 8080,
"tags": ["web", "api"],
"database": { "host": "localhost", "port": 5432 }
}
The YAML equivalent:
name: my-app
port: 8080
tags:
- web
- api
database:
host: localhost
port: 5432
Cleaner to read, and the quotes disappear. The catch: YAML re-interprets unquoted values, so a string like "yes" or "1.10" should stay quoted to avoid becoming a boolean or a float.
YAML to JSON
Going the other way wraps everything back in quotes and braces and drops comments. A value left unquoted in YAML gets its inferred type baked in — if YAML read 1.10 as the float 1.1, the JSON will contain 1.1, not "1.10". Quote ambiguous values in the source to keep them intact.
Convert it instantly
You don't need a script. Open the formatter, paste your JSON or YAML, pick the target format, and copy. It auto-detects the input and handles the type and quoting rules in both directions.
Pitfalls
- Comments are lost going to JSON — keep a YAML original if comments matter.
- Quote ambiguous strings first: versions, country codes,
yes/no, times. - Key order may change; don't rely on ordering for correctness.
Got a config file to check?
Open the config toolkit →