viewer.csslab.dev

YAML ↔ JSON Converter

Convert YAML to JSON and back, with the parser's own error position when it will not parse.

What is YAML?

YAML is a data format designed to be written and read by people: structure comes from indentation rather than brackets, strings usually need no quotes, and comments are allowed. It is a superset of JSON, so any valid JSON document is also valid YAML — which is why the two show up together in config files, CI pipelines, and Kubernetes manifests.

This converter turns YAML into JSON and JSON into YAML, validating as you type. When a document will not parse it shows the parser's own message, which names the line — with YAML the answer is almost always indentation, and the position matters more than any rewording of the error.

YAML is a data serialization language designed to be human friendly and work well with modern programming languages.
YAML 1.2.2 Specification, Chapter 1

Features

Both directions
YAML to JSON for feeding a config into an API or a test, and JSON to YAML for turning an API response into something a human will maintain.
Errors that point at a line
The parser's message is shown unmodified, because the line number is the useful part of a YAML error and the cause is nearly always indentation.
A real YAML parser
Anchors, aliases, multi-line block scalars, and multiple documents are handled by a full YAML 1.2 implementation rather than a regex approximation.
Nothing is uploaded
Deployment manifests and CI configuration hold hostnames, bucket names, and internal service topology. All parsing happens in your browser.

How to use

  1. 1

    Pick a direction

    YAML → JSON or JSON → YAML.

  2. 2

    Paste the document

    The converted output updates as you type.

  3. 3

    Fix errors where the parser points

    If parsing fails, the message names the line. Check the indentation there first — tabs and misaligned nesting cause most YAML failures.

  4. 4

    Copy the result

    Copy the converted document to your clipboard.

Frequently asked questions

Is JSON valid YAML?

Yes. YAML 1.2 is a strict superset of JSON, so any valid JSON document parses as YAML and produces the same data. The reverse is not true — YAML has comments, anchors, and unquoted strings that JSON cannot express.

Why does my YAML fail to parse?

Indentation, nearly every time. YAML forbids tabs for indentation, requires consistent spacing within a block, and treats a missing space after a colon as part of the key. A value beginning with a character such as *, &, or % also needs quoting.

Why did my version number turn into a different value?

Unquoted scalars are typed by pattern. Values like 1.10 become the number 1.1, and in YAML 1.1 parsers the words yes, no, on and off become booleans — the notorious "Norway problem" where the country code NO turns into false. Quote anything that must stay a string.

How do I keep a leading zero in YAML?

Quote it. Unquoted 03187 is read as a number and loses the zero; "03187" stays a string. The same applies to postal codes, phone numbers, and version strings.

Does this handle anchors and multiple documents?

Yes — a full YAML 1.2 parser is used, so anchors and aliases are resolved and block scalars are preserved. When converting to JSON, anchors are expanded because JSON has no way to express a reference.

Is my configuration sent anywhere?

No. Parsing and serialising both happen in your browser, and this page has no backend to receive anything.

Specifications this follows

Related tools