Skip to content

YAML to JSON Converter

Convert YAML to JSON, or JSON back to YAML, in one step.

  • Free, no account
  • Nothing uploaded
  • 13 tools
Input
Output
working…in 197 B · 12 linesProcessed in this tab, no request made

Nothing you paste is uploaded. The server sends connect-src 'self', so your browser blocks this page from contacting any other host. Check it yourself

Convert YAML to JSON and JSON to YAML in both directions, with multi-document streams and errors shown by line and column. Runs in your browser tab.

YAML to JSON, and back

YAML is parsed as YAML 1.2. Anchors and aliases are expanded, comments are dropped (JSON has none) and a stream of several documents becomes a JSON array.

defaults: &d
  retries: 3
job:
  settings: *d
  name: sync

{ "defaults": { "retries": 3 }, "job": { "settings": { "retries": 3 }, "name": "sync" } }

Switch to JSON → YAML for the other direction, or press Swap to feed the output back as input. Because YAML 1.2 is a superset of JSON, that direction loses nothing.

Things that surprise people in YAML

  • Indentation is structure, and tabs are not allowed for it. A stray tab is the most common parse error.
  • version: 1.10 is the number 1.1. Quote values that must stay text.
  • In YAML 1.1 parsers, no, on and off are booleans (the "Norway problem"). Here they are strings, per YAML 1.2.
  • A value containing : or starting with *, & or @ needs quotes.

The JSON side can be checked in the JSON validator.

Questions

Short answers to what people ask most.

Which YAML version is used?

YAML 1.2, through the "yaml" library. In 1.2 the words yes, no, on and off are plain strings, not booleans as in YAML 1.1. If a tool that reads your file follows 1.1 (some older parsers do), those words may be interpreted differently there.

What happens to anchors, aliases and comments?

Anchors and aliases are resolved, so the JSON contains the repeated data in full. Comments are dropped, because JSON has no comments.

What about files with several documents?

A stream separated by --- is converted to a JSON array with one item per document, and a note says how many were found.

Can every JSON document be written as YAML?

Yes. YAML 1.2 is a superset of JSON, so the JSON to YAML direction never loses data. The reverse can: YAML features such as tags and non-string keys have no JSON equivalent.