Dev Converters
JSON & YAML

YAML to JSON Converter

Convert YAML to JSON (pretty-printed, 2-space indent) in your browser. Handles anchors, multi-doc files, and nested structures.

How it works

YAML is a superset of JSON: any valid JSON document is valid YAML, but the reverse is not true. YAML adds features like anchors, tags, multiple documents per file, and raw multiline strings. When converting to JSON, those features have to be flattened: anchors get expanded, tags drop their type hints, and multi-document streams become a JSON array.

This converter uses js-yaml's `loadAll` to handle both single and multi-document streams transparently. Single-document input produces a JSON object or array; multi-document input produces a JSON array of documents. The parser follows YAML 1.2 semantics (failsafe + JSON + core schemas), so `true`, `null`, integers, and floats are recognised natively.

If your YAML has custom tags like `!Ref` (common in CloudFormation templates), the parser will reject them unless you switch to a schema that allows unknown tags. A common fix is to comment out or remove those lines before pasting. Tab characters are also a frequent source of errors — YAML forbids tabs for indentation; use spaces only.

Frequently asked questions

Does this support multi-document YAML?
Yes. If the input has `---` separators, the converter returns a JSON array with one entry per document.
What about YAML anchors and aliases?
Anchors (&) and aliases (*) are resolved before serialisation, so the JSON output has fully expanded values.
Are dates preserved?
YAML dates (ISO 8601) are parsed as JavaScript Date objects, then stringified as ISO strings in the JSON output.

Related tools