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
- JSON to YAML ConverterConvert JSON to clean, human-readable YAML instantly. Runs fully in your browser — no upload, no tracking.
- JSON to CSV ConverterConvert a JSON array of objects to CSV online. Auto-detects columns, escapes quotes, supports nested fields via dot notation.
- CSV to JSON ConverterConvert CSV to JSON online. Auto-detects delimiters, parses headers into object keys, and coerces numbers and booleans.
- JSON to TypeScript InterfaceGenerate TypeScript interfaces from a JSON sample. Infers types, nested shapes, and arrays. Output is ready to paste into your codebase.