YAML to JSON Converter
Fast and secure YAML to JSON conversion. Perfect for configuration files and data analysis.
Fast and secure YAML to JSON conversion. Perfect for configuration files and data analysis.
YAML and JSON are closely related formats — JSON is technically a strict subset of YAML 1.2 — and converting between them is usually straightforward. YAML adds human-friendly features that JSON lacks: comments, multi-line strings without escaping, anchor and alias references, more flexible quoting, and indentation-based structure that resembles natural document layout. This makes YAML the popular choice for configuration files (Kubernetes manifests, GitHub Actions workflows, Docker Compose) while JSON dominates API payloads.
Converting YAML to JSON usually means giving up YAML's human-friendly extras in exchange for a format that machines parse more easily and that is the lingua franca of HTTP APIs. Comments are dropped (JSON has none). Anchor references are resolved into their referent values. Multi-line strings collapse to standard JSON strings with embedded newlines.
This converter parses YAML using js-yaml, the most widely used YAML library in JavaScript. Output is generated using JSON.stringify with optional indentation. The conversion handles all standard YAML 1.2 syntax including flow style, block style, scalars, sequences, mappings, anchors, aliases, and the standard tag types.
Most APIs and many programming environments expect JSON. Configuration files written in YAML need to be converted to JSON when integrating with code or services that only accept JSON. Tooling for JSON is also more abundant: jq, JSON Path, JSON Schema, and a wide ecosystem of validators and transformers all assume JSON input.
JSON is also unambiguous in ways YAML is not. YAML's flexibility creates parsing surprises — strings like 'no' parsing as boolean false in YAML 1.1, version strings parsing as floats, indentation errors producing silent structural changes. Converting to JSON freezes the data into a less-ambiguous form.
Paste YAML, get JSON.
js-yaml implements YAML 1.2 with optional support for YAML 1.1 quirks (the 'no'-as-false issue, octal numbers without 0o prefix). The parser produces a JavaScript object tree using native types: numbers, strings, booleans, null, arrays, and plain objects.
JSON.stringify serializes the object tree to JSON. Optional indentation produces pretty-printed output; without it the result is compact single-line JSON. Special values (NaN, Infinity, undefined) are not valid JSON; the converter coerces them to null where present.
Edge cases: YAML timestamps become ISO-8601 strings in JSON. YAML binary data (base64-encoded) becomes a string. Anchors and aliases are resolved into duplicate values in JSON, since JSON has no reference syntax.