Paste YAML and get valid, formatted JSON in one step, with 2 or 4 space indentation and optional key sorting. The conversion runs entirely in your browser, so your data never leaves your device.
No installation, no signup. Results in milliseconds.
YAML and JSON carry the same data model: objects, arrays, and scalars. The converter parses your YAML into that data and re-serializes it as JSON. Where YAML shows structure with indentation and dashes, JSON shows it with braces and brackets. The information is identical; the syntax is what changes.
Most APIs, databases, and JavaScript code speak JSON, not YAML. When a config file or a fixture is written in YAML and you need to feed it to code or an API, converting to JSON gets it into the form your tools expect. JSON is also what JSON.parse accepts directly in the browser.
JSON has no comment syntax, so any YAML comment lines beginning with a hash are dropped from the output. That is expected, because comments are not part of the data. If you need the data validated afterward, the JSON parser confirms it, and the JSON formatter re-indents it.
Every YAML construct has a direct JSON equivalent. Here is what the converter writes for each.
| YAML | JSON output | Notes |
|---|---|---|
| Mapping | { } object | Each key: value becomes a quoted key and a value. |
| Sequence | [ ] array | Each - item becomes an array element. |
| Bare number | 42, -3.14 | Unquoted YAML numbers become JSON numbers. |
| Bare true / false | true / false | Read as booleans unless quoted. |
| null, ~ | null | Both null forms become the JSON null literal. |
| Quoted scalar | JSON string | A quoted YAML value stays a string. |
| # comment | (dropped) | JSON has no comments, so they are removed. |
The one thing to watch is YAML's implicit typing. A bare yes, on, or true is a boolean, and a bare 3 is a number, so each becomes a JSON boolean or number rather than a string. If a value must stay a string in the JSON, quote it in the YAML first. For the six JSON value types this produces, see what JSON is, and for the difference between the formats read JSON vs XML vs YAML.
A YAML config becomes JSON your code and APIs can parse directly.
The comment was dropped, the env mapping became a nested object, the ports sequence became an array, and replicas, false, and null kept their types. To go the other way, use the JSON to YAML converter, and for the rules behind the mapping read how to convert JSON to YAML.
Config lives in YAML, but code and APIs want JSON.
Everything developers ask about converting YAML to JSON.
Hands-on articles from our blog.
All free, all browser-based, no signup required.