YAML ⇄ JSON Converter

Pick a direction and paste — the conversion runs as you type, in this page.

How it works

YAML → JSON reads a deliberately bounded, practical subset of YAML: block mappings and sequences nested by 2-space indentation (including a sequence of mappings), inline flow collections like [a, b, c] and {a: 1, b: 2}, quoted and unquoted scalars, and # comments. Anchors, aliases, multi-document ---/... streams, explicit tags like !!str, and literal/folded block scalars (| and >) are out of scope and produce a clear error naming the feature instead of a wrong result.

JSON → YAML serializes any JSON value as block-style YAML: objects become nested key: blocks, arrays become - lines, and a string is wrapped in double quotes only when left bare it would be ambiguous — it contains : or #, has leading/trailing whitespace, or would otherwise parse back as a keyword like true/null or a number.

Frequently asked questions

What YAML features are NOT supported?

Anchors and aliases (&name / *name), multi-document streams separated by --- or ..., explicit tag directives like !!str, and literal/folded block scalars (| and >) are all out of scope — the converter throws a clear error naming the feature instead of silently mis-parsing it. Everything else a typical config file uses — mappings, sequences, inline [a, b] / {a: 1} flow collections, quoted and unquoted scalars, comments — is supported.

Why do my YAML comments disappear when I convert to JSON?

JSON has no comment syntax at all, so there is nowhere for a # note to go once the document becomes JSON — it is stripped during parsing rather than carried through as dead text that would make the output invalid JSON.

When should I reach for this instead of a full YAML library?

This covers the shape of YAML that shows up in everyday config files: nested settings, lists, simple values. If you are working with a document that uses anchors to avoid repetition, splits into multiple --- documents, or relies on block scalars for multi-line text, a real YAML library (js-yaml, PyYAML, ...) is the right tool — this one is deliberately bounded rather than spec-complete.