Handitab

YAML ↔ JSON

Convert YAML to JSON or JSON to YAML in either direction, with syntax checked along the way and the line of any error reported.

About YAML ↔ JSON

YAML is a human-readable data serialization format that uses indentation for structure and is a superset of JSON. This tool uses the js-yaml 4 library, which implements YAML 1.2, to parse the input and report syntax errors with their line and column. Formatting writes the parsed data out again, so comments are removed and anchors are expanded. Files that hold several documents separated by three hyphens are rejected.

How to use YAML ↔ JSON

  1. Type or paste into the "YAML or JSON" box, or press "Use example" to try it with sample data.
  2. Set "Conversion" if the defaults do not fit.
  3. The result appears below and updates as you type.
  4. Copy the result with the copy button, or download it as a file where that is offered.

Questions about YAML ↔ JSON

Why did my comments disappear after formatting?

The formatter parses YAML into data and writes that data out again. Comments are not part of the data model, so they are dropped. Anchors and aliases are also replaced by the values they point to.

Is every JSON document valid YAML?

In practice yes. YAML 1.2 was designed as a superset of JSON, so a JSON file can be loaded by a YAML parser. The reverse is not true: YAML features like anchors and comments have no JSON form.

Runs in your browser. Page last updated .

More encoding and data tools

All 28 encoding and data tools