YAML to JSON
Paste YAML or open a file to get JSON. Errors show their line and column, numbers stay exactly as written, and nothing leaves your device.
Paste or type YAML, or open or drop a file of up to 25 MB. It stays on this page: nothing is sent anywhere or saved.
Paste YAML above to see it as JSON.
Everything happens on this page, on your device: your YAML is never sent anywhere or saved.
Turn YAML into JSON, read the way YAML 1.2 says
Config files, build pipelines and data exports often use YAML, while many programs and APIs want JSON. This page reads YAML with the yaml library, following the YAML 1.2 core schema, and writes the same data as JSON.
How to use it
- Paste or type YAML, or open or drop a file of up to 25 MB.
- Read the line under the options: what was converted, or the first error with its line and column.
- Choose a layout, and tick Merge keys if your file uses << to copy one mapping into another.
- Copy the JSON, or download it as a .json file.
What “YAML 1.2 core schema” means
It’s the standard set of rules for what a plain value is. Only true and false (also True, TRUE, False, FALSE) are true or false, and null, ~ or nothing at all is null. Words such as yes, no, on and off stay text; the tool points them out, because older YAML 1.1 programs read them as true or false. A number with a leading zero, like 012, reads as 12, which matters for ZIP codes.
How the rest converts
- Several documents, separated by ---, become a JSON array with one item each.
- Anchors and aliases (&name and *name) are replaced by the data they point to. The library stops a document whose aliases would repeat their anchors about 100 times or more, which guards against the “billion laughs” attack.
- Numbers are written as typed when JSON allows it, so 12345678901234567890 and 1.10 stay exact; 0x1F becomes 31, and .inf and .nan become null.
- Keys are always text in JSON, so 1: a gives "1". A key that’s a list or a mapping is an error.
- Block text (| and >) and quoted strings become ordinary JSON strings, with line breaks written as \n.
- Custom tags, such as !Ref, are refused with a clear message, and so are YAML 1.1 tags such as !!binary.
Good to know
- Repeated keys and tabs used for indentation are errors, as YAML itself says. Comments aren’t kept: JSON has none.
- A large file can take a while to convert; Cancel stops it.
- Already have JSON? The JSON Formatter checks and tidies it; this page converts YAML into JSON. To go back, use JSON to YAML.