YAML and JSON describe the same kind of data, so you can move between them freely. You write a Docker Compose or GitHub Actions file in YAML because it reads cleanly, then an API hands you JSON because that is what machines prefer. This guide shows how to convert YAML to JSON and back, and how to avoid the gotchas that bite people along the way.
YAML vs JSON, the short version
YAML is actually a superset of JSON, which means any valid JSON is already valid YAML. The difference is style and strictness.
- YAML uses indentation instead of braces, supports comments with
#, and is built for humans editing config by hand. You see it in CI pipelines, Docker Compose, and Kubernetes manifests. - JSON uses braces and brackets, has no comments, and is stricter about quoting and commas. It is what REST APIs send and what most languages parse fastest.
So this YAML:
# a small config
name: Ada
roles:
- admin
- editor
becomes this JSON:
{
"name": "Ada",
"roles": ["admin", "editor"]
}
Note that the comment vanishes. JSON has no place to put it, so any # lines are dropped on the way over.
Convert YAML to JSON in three steps
- Open the YAML to JSON Converter and paste your YAML or drop in a file.
- Pick the direction, YAML to JSON or JSON to YAML, and the converter parses your input.
- Click Convert, review the output, then Copy or download the result.
Everything runs on your device. Your config is never uploaded, which matters when it holds API keys, database passwords, or anything you would not paste into a random website.
Common YAML gotchas
Most failed conversions come from YAML being picky in ways that are easy to miss. The YAML to JSON Converter will flag a parse error, and these are usually the cause.
- Tabs are not allowed. YAML indentation must be spaces, never tabs. A stray tab character is the most common reason a file refuses to parse. Set your editor to insert spaces.
- The Norway problem. Unquoted
no,yes,on, andoffare read as booleans, so a country codenobecomesfalseinstead of the string “no”. Wrap such values in quotes:country: "no". - Numbers that should be strings. A version like
1.10parses as the number1.1, dropping the zero. Quote it as"1.10"to keep it intact. - Ambiguous values. Things that look like dates, large numbers, or special words can be coerced into types you did not intend. When in doubt, quote the string.
If your output looks wrong, check indentation first, then look for unquoted values that YAML guessed the type of.
Why do it in the browser
Because the parsing happens locally, your config never leaves your machine. That is the whole point when the file is full of secrets like tokens and connection strings. There is no upload, no round trip, and no server log holding your data. Large files still work, they just take a moment to render.
Related tools
- Cleaning up the JSON afterward? Beautify or validate it with the JSON Formatter.
- Need a different target format? Turn objects into markup with JSON to XML.
- Working with spreadsheet data instead? Convert rows with CSV to JSON.
Paste your YAML, pick a direction, convert, and copy clean JSON in seconds.