YAML to JSON Converter
Convert YAML to JSON with anchors and merge keys resolved, YAML 1.2 or 1.1 typing for yes/no, and a warning for numbers JSON cannot hold. How it works
Use the YAML to JSON Converter
Your YAML is kept in this browser only (local storage) so it is still here next visit; nothing is uploaded. Limit: 100,000 characters. Anchors and merge keys (<<) are resolved, and YAML 1.2 is read by default: yes, no and on stay text.
{
"name": "John",
"age": 30,
"active": true,
"tags": [
"dev",
"ops"
]
}About the YAML to JSON Converter
In YAML to JSON conversion, true becomes true but yes stays the text "yes", because this converter reads YAML 1.2 by default and YAML 1.2 treats only true and false as booleans. Tick the YAML 1.1 option for files written for older readers: then yes, no, on and off become booleans and 017 is the octal number 15.
How YAML values come out in JSON
| YAML value | JSON with YAML 1.2 (default) | JSON with the YAML 1.1 option |
|---|---|---|
| yes | "yes" | true |
| no | "no" | false |
| on | "on" | true |
| off | "off" | false |
| y | "y" | true |
| NO | "NO" | false |
| true | true | true |
| "yes" | "yes" | "yes" |
| 017 | 17 | 15 |
| 0o17 | 15 | "0o17" |
| 0x1F | 31 | 31 |
| 1_000 | "1_000" | 1000 |
| 12:30 | "12:30" | 750 |
| 2024-01-15 | "2024-01-15" | "2024-01-15T00:00:00.000Z" |
| ~ | null | null |
| 1.10 | 1.1 | 1.1 |
| 9007199254740993 | 9007199254740992 | 9007199254740992 |
| .nan | null | null |
Each row is the JSON for a: followed by the value. 12:30 in YAML 1.1 is a base-60 number (12 × 60 + 30). The last two rows come with a warning: 9007199254740993 loses its last digit because JSON numbers are 64-bit floats, and .nan has no JSON form.
Frequently asked questions
- Why does yes stay a string in the JSON?
- YAML 1.2, the default here, reads only true and false (as true, True or TRUE) as booleans, so yes, no, on and off are text. YAML 1.1 also read those words, plus y and n, as booleans. Tick the YAML 1.1 option to read them that way, or write true and false.
- Are anchors, aliases and merge keys supported?
- Yes. &name and *name are expanded, and a << merge key copies a mapping in, so a base of x: 1 merged into a mapping with y: 2 gives {"x":1,"y":2}. Expansion stops at 50,000 values and 2,000,000 characters of JSON, which keeps a hostile file from freezing the page.
- What happens to a file with several documents?
- Documents separated by --- become one JSON array in their order, and a note says so: a: 1, then ---, then b: 2 gives [{"a":1},{"b":2}].
- Why did my large number change?
- JSON numbers are 64-bit floats, which hold whole numbers exactly only up to 9,007,199,254,740,991. 9007199254740993 comes out as 9007199254740992, and the converter warns about it. Quote IDs and other long numbers in the YAML to keep them as text.
- Is my YAML saved?
- Yes, in this browser’s local storage, so it is still there on your next visit; it is not uploaded. Clear Saved Values removes it and brings back the example.
Related Tools
View all toolsCSV to JSON
Convert CSV to JSON: the first row becomes the keys, quoted commas and line breaks are kept, and numbers and booleans are detected only if you ask.
JSON to CSV
Turn JSON into CSV: an array of objects, one object or a list of values. Flatten nested objects, expand arrays into rows, then copy or download.
XML to JSON Converter
Convert XML to JSON and JSON back to XML: attributes go under @attributes, repeated elements become arrays, and an XML error shows its line and column.
JSON to YAML
Convert JSON to YAML in block or flow style. Text such as yes or 017 is quoted so it stays a string, and a JSON error shows its line and column.
SQL to JSON
Turn SQL INSERT statements, or a result table pasted from psql, MySQL or Markdown, into JSON. Quoted values stay strings; numbers, true and NULL get types.
JSON to SQL
Generate SQL INSERT statements, and CREATE TABLE if you want it, from JSON for PostgreSQL, MySQL, SQLite or SQL Server, with types inferred from every row.