One converter for both directions, with errors that point at the line
YAML and JSON describe the same data in different clothes: config files, API payloads, Kubernetes manifests and CI pipelines constantly need translating between them. This converter runs both directions, formats JSON pretty (2 or 4 spaces) or minified, and — the part most online converters skip — reports YAML problems with the line number, because "invalid YAML" is not a diagnosis. It is powered by the js-yaml library, vendored on this site, and your input is parsed in your browser only.
Both directions go through the parsed data model, so what survives is the data, not the formatting: comments and YAML anchors do not exist in JSON and are not carried over.
Worked example
Press Load sample: a small YAML document describing this site — strings, a number, a boolean, a list and a nested map — converts to indented JSON with every value intact, and converting that JSON straight back returns equivalent YAML. Round-trip integrity is the test that matters, and it is the test this page is built around.
How to use this converter
- Paste your YAML (or JSON) into the input box, or press Load sample to see the shape of a conversion.
- Press YAML → JSON or JSON → YAML. The output appears in the Output box below the tool; the status line confirms validity or shows the error and its line.
- Choose pretty or minified JSON formatting before converting, if the JSON is headed for a file (pretty) or a payload (minified).
- Copy the output with the Copy button, or select and edit it directly in the output box.
What survives conversion — and what does not
Strings, numbers, booleans, null, arrays and nested objects all round-trip cleanly. Three things do not: comments (JSON has no comments), YAML anchors and aliases (expanded into plain data), and key order in JSON objects (preserved as written by JSON.parse in practice, but not something JSON guarantees). Dates in YAML become strings in JSON, because JSON has no date type — if a downstream tool expects a timestamp, that is a schema decision, not a conversion bug.