What it does
- JSON: indent with 2 or 4 spaces or a tab, or minify to one line (the same layout as Python
json.dumps). Numbers are kept as written, so big integers such as12345678901234567890and digits like1.50are not lost. Syntax errors are reported at the same line and column as Pythonjson. - YAML → JSON: the syntax is read by the proven yaml library (ISC); unquoted values are resolved with the rules of the selected version — the core schema of the 1.2 spec, or the same rules as PyYAML for 1.1 (including the
<<merge key). Values the two versions read differently are listed in a table. - JSON → YAML: values such as
"no","0777"and"2001-12-14"are quoted so that they stay text in either version. The result is read back before it is shown to make sure the values are the same.
YAML traps
| Unquoted value | YAML 1.2 | YAML 1.1 (PyYAML) |
|---|---|---|
no · on | text "no" · "on" | false · true |
0777 | 777 | 511 (octal) |
0o17 | 15 | text "0o17" |
2001-12-14 | text | a date — JSON has no date type, so the original text is written |
1:20 | text | 80 (base 60) |
1_000 | text | 1000 |
1e3 | 1000.0 | text "1e3" (a 1.1 float needs a dot) |
y | text | text (PyYAML) — a boolean in the 1.1 spec table, so it is quoted on output |
The country code NO (Norway) turning into false is the first row of this table. If a config file is read by a 1.1 parser such as PyYAML, select 1.1 to check it.
How the check was made
Before release 244 cases were compared, all matching: 25 JSON documents × (2 spaces, 4 spaces, one line, sorted keys) = Python json.dumps(ensure_ascii=False) for 100 cases (two documents whose number spellings are kept and one with an unpaired surrogate were compared by value), the line and column of 32 broken JSON inputs = Python json, 35 YAML documents converted as 1.1 = PyYAML 6.0.3 safe_load (inputs that give an error also fail in PyYAML or hold values JSON cannot express), the 1.2 reading of the same YAML = the yaml library's core schema in 34 cases, 25 JSON → YAML results read back by PyYAML and ruamel.yaml 0.19.1 = the original values, and the 18 trap values above.
Common mistakes
- A trailing comma
[1, 2,], single quotes{'a': 1}or comments — all errors in JSON. - Tabs in YAML indentation — YAML does not allow tabs for indentation.
- Reading big IDs with
JSON.parse— integers beyond 2⁵³ are rounded. Send them as strings. - Writing the same key twice — JSON parsers usually take the last value, but YAML forbids it and some parsers stop with an error.
FAQ
Which YAML version should I pick?
The one used by the program that reads the file. Python's PyYAML reads 1.1 and JavaScript's yaml reads 1.2. Some mix the two — ruamel.yaml 0.19 defaults to 1.2 but read 2001-12-14 as a date and 1_000 as 1000 in our pre-release test. For other libraries, check their documentation. If you do not know, quoting the values from the trap table is the safe choice.
Why are tags such as CloudFormation !Ref not converted?
JSON has no tags, so any conversion would lose the meaning. Instead of guessing, the tool reports the position as an error.
Is what I paste sent to a server?
No. Everything is calculated in your browser and the input is not written to the address bar or browser storage. It is not passed to the visitor statistics or the ads this site uses. Details are on the privacy page.