Skip to main content
Tools

JSON to YAML

Convert JSON to YAML and YAML to JSON, keeping key order and pointing to the line and column of syntax errors.

Indent

0 characters · 1 line

How to use

  1. Pick a direction: “JSON → YAML” or “YAML → JSON”.
  2. Paste your input, or click “Example” to try it. The result appears instantly, and syntax errors show the line, column and reason.
  3. Choose an indent. When writing YAML you can turn on “YAML 1.1 compatible”; when reading YAML you can parse it with YAML 1.2 or 1.1 rules.
  4. Click “Swap” to move the result to the input and switch direction, handy for checking a round trip.
  5. Click “Copy” or “Download” to grab the result.

FAQ

Is my data uploaded?

No. The conversion runs entirely in your browser and your data never leaves your device. The YAML library is downloaded from this site the first time you convert, and is not needed again after that.

What is the difference between YAML 1.1 and 1.2? Why does no become false?

YAML 1.1 treats yes, no, on, off, y and n as booleans, 0755 as an octal number and 1:30 as a base-60 number (90). YAML 1.2 only accepts true and false, and 0755 is the decimal 755. Many older libraries (such as PyYAML and Go’s yaml.v2) still follow 1.1, so the country code NO (Norway) can turn into false. With “YAML 1.1 compatible” on, such strings are quoted so every reader sees a string.

What happens with several YAML documents separated by ---?

JSON can only have one top-level value, so by default all documents are put into an array in order. You can also convert just the first document. Kubernetes files often hold several resources in one file; as an array they can be processed in one go.

Is key order kept? Are large numbers safe?

Yes. Both directions keep the original key order (including numeric keys such as "1" and "2"). Integers beyond JavaScript’s safe range, such as 12345678901234567890, are kept exactly, and spellings like 1.0 stay unchanged.

Are YAML comments, anchors and aliases kept?

JSON has no comments, so they are dropped when converting YAML to JSON. Anchors (&) and aliases (*) are expanded into their values, and merge keys (<<) are applied. To tidy up YAML while keeping comments, use the YAML Formatter.

How are YAML values that JSON lacks converted?

.inf and .nan become null. When parsing as YAML 1.1, dates become ISO 8601 strings, !!binary becomes a Base64 string and !!set becomes an array. Keys that are not strings (numbers or arrays, for example) are turned into strings or JSON text, with a note.

Keyboard shortcuts

/
Search tools (on a tool page, goes to the homepage search)
?
Show this help
Esc
Close a dialog
Ctrl / ⌘Enter
Run the tool's main action (where supported)

While you type in a text field, / and ? are typed as usual.