Modern Niche World MNW

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

  1. Paste or type YAML, or open or drop a file of up to 25 MB.
  2. Read the line under the options: what was converted, or the first error with its line and column.
  3. Choose a layout, and tick Merge keys if your file uses << to copy one mapping into another.
  4. 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.

Frequently asked questions

Why does yes stay "yes" instead of becoming true?
YAML 1.2, the current version, reads yes, no, on and off as ordinary words. YAML 1.1 read them as true and false, and some programs still do, so the tool points them out. If you mean true or false, write true or false.
Why does it stop at a custom tag?
Tags such as !Ref or !include tell one particular program to do something with a value. JSON has no tags, and turning them into data would mean guessing, so the tool names the tag and its line. Remove the tag to convert the value as plain text.
What happens to anchors and aliases?
Each alias is replaced with a copy of the data its anchor marks, so the JSON holds the data in full. If aliases would repeat their anchors too many times, the conversion stops instead of building an enormous file.
Is my YAML sent anywhere?
No. It’s converted by this page’s code, in a background worker on your device. Nothing is sent, logged or saved, so it’s safe for config files with keys or tokens in them.