YAML to JSON and Back

Paste YAML to get JSON, or switch direction and paste JSON to get YAML. A mistake is reported with its line and column, and nothing leaves this page.

How it works

YAML is read with the yaml package, the same one the YAML Formatter uses. Reading follows YAML 1.2, the current spec, unless you switch on YAML 1.1. Anchors, aliases and << merge keys are resolved, so the JSON holds the values they point to.

Integers too long for a JavaScript number are kept as text while converting and written back digit for digit. .inf and .nan have no JSON form, so they become null and the note says how many.

JSON is read with a parser that keeps key order and the exact digits of every number. When it is written as YAML, any string that a YAML 1.1 reader would take as a boolean, number, date or null gets quotes, so the file means the same thing to old and new readers.

How to use it

  1. 1 Pick the direction: YAML to JSON, or JSON to YAML.
  2. 2 Paste your text into the box. The result appears as you type.
  3. 3 Choose the indent. For JSON you can also write everything on one line.
  4. 4 Read the note under the result for warnings, then press Copy result or Download.

Good to know

  • Reading a file written for PyYAML or older Kubernetes tools? Switch on YAML 1.1 so yes, no, on and off become true and false, as those tools read them.
  • A YAML file with several documents separated by --- becomes a JSON array, one item per document.
  • Comments are lost in both directions, because JSON has no place to keep them.
  • Duplicate keys are refused with their line, because JSON readers would silently keep only one of them.

Browser support

  • Chrome 94 and later
  • Firefox 93 and later
  • Safari 16.4 and later
  • Edge 94 and later

These are the oldest versions with everything the tool uses. They are worked out from the tool itself, so they change when it does.

Version numbers checked on 2026-09-04.

YAML and JSON hold the same data, until they do not

JSON and YAML describe the same things: maps, lists, text, numbers, true, false and null. Every JSON document is almost valid YAML already. So converting between them looks like a simple job, and most of the time it is. The trouble is in a few places where the two formats, or two versions of YAML, read the same characters as different values. A converter that ignores those places changes your data without telling you.

The best known case is the boolean. YAML 1.1, which PyYAML and many older tools still follow, reads yes, no, on, off, y and n as true or false. YAML 1.2, the current version, reads them as text. A GitHub Actions file with on: push means the key "on" to one reader and the key true to another. This tool reads YAML 1.2 by default and has a switch for 1.1. When it writes YAML, it puts quotes around every string a 1.1 reader would misread, such as "yes", "NO", "1.0" and "2024-01-01". Quotes are harmless to a 1.2 reader, so the output means the same thing to both.

Numbers are the second case. A database ID such as 12345678901234567890 is longer than a JavaScript number can hold, so a converter built on JSON.parse quietly turns it into 12345678901234567000. This tool keeps whole numbers as text while it works and writes them back digit for digit, in both directions. Infinity and not-a-number are the other edge: YAML has .inf and .nan, JSON has no way to write them. They become null, and the note under the result says how many were changed, so you can decide what they should be.

Structure is the third. YAML can have several documents in one file, separated by ---. JSON has one value per file, so several documents become an array with one item each, and the note says so. YAML anchors and aliases let one value appear in many places. JSON has no references, so each alias is replaced by a copy of its value, and merge keys are merged in. Duplicate keys are refused with their line number, because a JSON reader would keep only one of them and lose the other without a word.

Two things do not survive the trip. Comments are dropped, because JSON has nowhere to store them. Formatting choices such as block or flow style, and quoting you chose by hand, are also not kept: the YAML that comes out is written fresh in block style. Everything runs in your browser, up to 500 KB at a time, so a configuration file with passwords or tokens in it is never sent anywhere.

Frequently asked questions

Why did "NO" get quotes in my YAML?

A YAML 1.1 reader, such as PyYAML, reads a bare NO as the boolean false. That is the "Norway problem": a country code turns into false. The tool quotes every string that a 1.1 reader would misread, so the value stays text for every reader.

Does it keep large IDs exactly?

Yes, for whole numbers. 12345678901234567890 comes out with every digit in both directions. A decimal with more digits than a JavaScript number holds is rounded when written as YAML, and the note lists it.

What happens to anchors and aliases?

They are resolved. JSON has no references, so each alias is replaced by a copy of the value it points to, and merge keys (<<) are merged in.

How large a file can it convert?

Up to 500 KB of text at a time. Past that it says so rather than freezing the page. Split a larger file into parts.

Is my file uploaded?

No. The conversion runs in this page, so configuration files with secrets in them stay on your device.

Related tools

Your files are processed on your device and are not uploaded. You can verify this in your browser’s developer tools under the Network tab.