JSON ↔ YAML Converter
Convert between JSON and YAML in either direction. The input is validated first and syntax errors are reported with the line and column. Conversion keeps key order and large numbers exactly. YAML is parsed as data only: nothing in it is ever executed, and files that try to expand without limit are refused. Everything runs in your browser.
Result
- Documents
- Input size
- Output size
Examples
The same data in YAML and in JSON:
| YAML | JSON |
|---|---|
name: Ana
age: 30 | {"name":"Ana","age":30} |
- red
- green | ["red","green"] |
a:
b: [1, 2]
c: null | {"a":{"b":[1,2]},"c":null} |
Formula & Methodology
JSON is parsed by a strict parser written for this site; YAML is parsed by the maintained “yaml” library (YAML 1.2) in data-only mode. The data is then written in the other format. Key order, large integers and text are kept exactly, and YAML output is generated with the library’s own quoting rules so that strings are never misread as numbers, booleans or null.
Notes and limitations
- Comments, anchors and YAML formatting choices (block or flow style) are not preserved when converting to JSON, because JSON has no equivalent.
- YAML 1.2 rules apply: yes, no, on and off are plain strings, not booleans. Turn on the quoting option if the YAML will be read by an older YAML 1.1 parser.
- Aliases are limited to 100 expansions per file, which rejects “billion laughs” files, and duplicate keys are rejected.
- Values that JSON cannot represent (NaN, Infinity) become null, and several YAML documents become a JSON array. A warning tells you when this happens.
- Custom YAML tags are treated as plain data and are never run. Texts up to 5,000,000 characters are accepted.
How to Use
- Choose JSON to YAML or YAML to JSON.
- Paste your text. It is checked as you type and errors show the line and column.
- Choose the indentation and, if you wish, sort the keys.
- Read any warnings, then copy the result or download it as a file.
- Use the reverse button to convert the result back and check the round trip.
Frequently Asked Questions
Is my data uploaded?
No. Parsing and conversion run in your browser and nothing you paste is sent to ToolQuarter, analytics or any other service.
Is it safe to paste YAML from an untrusted source?
Yes, for conversion. The YAML is parsed as plain data: tags that some languages use to run code are not run, and files that expand without limit (alias bombs) are refused.
Why does my YAML value “yes” stay a string?
This tool follows YAML 1.2, where only true and false are booleans. Older YAML 1.1 parsers read yes, no, on and off as booleans, so use the quoting option when writing YAML for them.
Are comments preserved?
No. JSON cannot hold comments, so they are dropped when converting YAML to JSON, and JSON has none to carry into YAML.
What happens to very large numbers?
They are kept exactly. JavaScript’s own JSON tools round integers above 9,007,199,254,740,991, but this tool writes the digits you gave it.
Last updated: