PlayTools

YAML to JSON Converter

Convert YAML to JSON in your browser, with a choice of indent or minified output and clear parse-error messages. Anchors and aliases are expanded.

Runs in your browser — nothing you enter is uploaded

YAML is a superset of JSON, so anything valid here maps cleanly to a JSON value. Comments are dropped (JSON has none), anchors and aliases are expanded to plain data, and dates become ISO strings. Multi-document YAML (streams separated by ---) is not supported — this converts a single document. Parsing happens entirely in your browser.

YAML and JSON: the same data, different clothes

JSON and YAML describe the same three things — mappings, sequences and scalars — so any YAML document that holds plain data has an exact JSON equivalent. JSON is in fact a strict subset of YAML. This converter parses the YAML into an in-memory value and re-serialises it as JSON, which is why round-tripping data through it is lossless for anything JSON can represent.

What does not carry over is everything JSON lacks a slot for. Comments are the big one: YAML "#" comments are stripped because JSON has no comment syntax. Anchors and aliases (&x / *x) are resolved — the JSON gets a full copy wherever the alias appeared, not a reference. Custom tags (!!python/object and the like) are not supported and will error.

Scalar interpretation follows the core schema. true and false are booleans; the YAML 1.1 habit of treating yes, no, on and off as booleans is not applied, so those stay strings. A bare number is a number; a date-like value such as 2024-01-01 is kept exactly as written, as a string (JSON has no date type); and everything else is a string. Quote a value in the YAML if you need to force it to stay text.

Two common errors: YAML forbids tab characters for indentation — use spaces — and this tool converts a single document, not a multi-document stream separated by "---". The parser reports the line and column of a syntax error so you can find it quickly.

Parsing and serialising run entirely in your browser via the js-yaml library. Nothing you paste is uploaded, and the tool works offline once loaded.

Worked example

YAML in:
port: 8080
hex: 0x1F
enabled: yes
release: 2024-01-01
big: 12345678901234567890
base: &base {timeout: 30}
prod: *base

JSON out:
{"port":8080,"hex":31,"enabled":"yes","release":"2024-01-01",
 "big":12345678901234567000,"base":{"timeout":30},"prod":{"timeout":30}}

Note what changed: the hexadecimal number became decimal, yes stayed a string (YAML 1.2), the date stayed text, the anchor was expanded into a full copy, and the very large integer lost precision — JavaScript numbers are exact only up to 9,007,199,254,740,991. Quote big IDs in the YAML so they come through as strings.

Fixing common parse errors

  • Tabs: indentation must use spaces only.
  • Colons in values: “title: Part 2: The Return” is ambiguous — quote the value.
  • A value starting with @, `, *, & or ! needs quotes, because those characters have special meaning at the start of a scalar.
  • Multiple documents separated by --- must be converted one at a time.

Why convert YAML to JSON

  • Validation: JSON Schema tools and many editors validate JSON more readily; convert a config file to check it against a schema.
  • Querying: jq and most programming languages read JSON natively, which makes it easy to pull a single value out of a large Kubernetes manifest or CI file.
  • APIs: most REST APIs accept JSON, not YAML, so request bodies written as YAML for readability need converting before they are sent.
  • Debugging: seeing the resolved data — anchors expanded, types made explicit — shows what the program reading the YAML will actually receive, which is often where indentation mistakes reveal themselves.

In-depth guides

These free tools pair well with this page — open them in a new tab to finish your workflow.

Frequently Asked Questions

Is every YAML file convertible to JSON?

Every YAML document that represents plain data (mappings, sequences, scalars) converts cleanly, because JSON is a subset of YAML's data model. What does not survive the trip is anything JSON has no concept of: comments are dropped, and custom YAML tags will fail or be coerced.

What happens to comments?

They are removed. JSON has no comment syntax, so the # comments in your YAML cannot be represented and are discarded during parsing.

How are anchors and aliases handled?

They are resolved. A value defined with &anchor and reused with *alias is expanded so the JSON contains a full copy at each place the alias appeared. The reference itself is not preserved.

What about dates and other special scalars?

The converter follows the YAML 1.2 core schema. Dates such as 2024-01-01 stay strings — JSON has no date type, and the original text is kept exactly. "yes", "no", "on" and "off" are strings too; only true and false are booleans. Hexadecimal (0x1F) and octal (0o17) numbers become ordinary decimal numbers (31 and 15).

Does it support multi-document YAML?

No. YAML streams that contain several documents separated by --- are not supported here; the tool converts a single document. Split the stream and convert each part separately.

Why do I get a parse error on tab characters?

YAML forbids tabs for indentation — only spaces are allowed. If your file was indented with tabs, replace them with spaces and it will parse. The error message shows the line and column.

Is my data uploaded?

No. Parsing and serialising happen entirely in your browser with the js-yaml library. Nothing is sent to a server.