Convert YAML to JSON without leaving the browser
YAML and JSON describe the same kind of data, just with different syntax. YAML is friendly to write by hand (Kubernetes manifests, GitHub Actions, CI configs, Docker Compose), while JSON is what most APIs, build scripts, and JavaScript code actually consume. Sooner or later you need to move a chunk of data from one to the other: pasting a config into a tool that only takes JSON, debugging why a parser chokes, or just reading a deeply nested YAML file as plain JSON.
You can do this with a one-line script if you have Python or Node handy, but when you just need a quick, correct answer, a browser tool is faster. This guide walks through converting YAML to JSON (and back) using a free converter, plus the small settings that matter and the errors that trip people up.
How to convert YAML to JSON
-
Open the YAML to JSON converter. It loads as a two-pane editor: your YAML goes on the left, the JSON result appears on the right.
-
Add your YAML. Paste it directly, use the Paste button to pull from your clipboard, or type it in. If you just want to see how it behaves, load the built-in sample first and edit from there.
-
Watch the JSON update live. The converter parses as you type, so there's no "Convert" button to hit. The moment your YAML is valid, the JSON appears on the right. If something is wrong, you get an inline error instead of a result.
-
Pick your indentation. Use the indent control to choose 2 spaces, 4 spaces, or tab. Two spaces is the common default for JSON; match whatever your project's linter expects so the output drops in cleanly.
-
Choose pretty or minified. Keep the pretty/format toggle on for readable, indented JSON. Switch to minified when you want a single compact line, for example to paste into an environment variable or a URL parameter.
-
Grab the result. Click Copy to put the JSON on your clipboard, or Download to save it as a
.jsonfile. Use Clear to empty the editor and start over.
That's the whole loop: paste, check, copy. Because the parsing happens with JavaScript right in your browser, your data never leaves the device, there's nothing to upload, and you don't need an account.
How to convert JSON back to YAML
Going the other direction is just as quick. Open the JSON to YAML converter, paste your JSON, and copy the YAML it produces. This is handy when an API hands you JSON but your config files are YAML, or when you want the more readable format for a long block of settings. The two converters are mirror images, so you can round-trip data between them.
If your goal is cleaner YAML rather than a format change, run it through the YAML formatter instead. It re-indents and tidies the structure without converting anything, which is useful for fixing the spacing mistakes that cause most YAML errors.
Tips
- YAML is whitespace-sensitive; JSON is not. A single misaligned space or a stray tab will break YAML parsing. If conversion fails, check indentation first, before anything else.
- Quote ambiguous values. Bare
yes,no,on,off, andtrue/falsebecome booleans, and unquoted numbers become numbers. If you want the literal string"yes"or a version like1.10kept exactly, wrap it in quotes in your YAML. - Comments don't survive. JSON has no comment syntax, so any
#comments in your YAML are dropped on conversion. That's expected, not a bug. - Match your project's style. Set the indentation to whatever your repo already uses (2 vs 4 spaces) so the copied JSON passes lint without a reformat.
- Need a schema next? Once you have clean JSON, you can feed it into the JSON Schema generator to produce a schema that validates documents of the same shape.
Common problems
- "bad indentation" or "could not find expected ':'": Almost always mixed tabs and spaces, or a list item indented under the wrong key. YAML does not allow tabs for indentation. Replace tabs with spaces and align nested items consistently.
- Output looks like a string, not an object: If your entire YAML got wrapped into one quoted string, you probably have an unescaped special character (a
:inside an unquoted value, for instance). Quote the value to fix it. - Duplicate keys silently overwrite: YAML keeps the last value when the same key appears twice at one level, so a key you expected may vanish from the JSON. Search your YAML for repeated keys if a field is missing.
FAQ
Is YAML really a superset of JSON? Yes. Valid JSON is also valid YAML, which is why these converters can move between them so cleanly. The differences are mostly syntax and a few YAML-only features (anchors, comments, multiple documents) that have no JSON equivalent.
Will my data be uploaded anywhere? No. The YAML to JSON converter does the parsing locally in your browser with JavaScript. Nothing is sent to a server, so it's safe for config files that contain internal hostnames or other private details. (There's no sign-up either.)
Why did my numbers or dates change format?
The converter reads YAML values by type. A version string like 1.20 becomes the number 1.2, and a date may be parsed as a timestamp. If you need an exact string, quote it in the YAML so it's treated as text rather than a number or date.
Can I convert TOML the same way?
Not with this tool, but a sibling converter handles it. Use the TOML to JSON converter for .toml config files like Cargo or pyproject.
For more on chaining these utilities into a workflow, see the essential developer tools guide.