Convert YAML to JSON

Paste YAML — a Kubernetes manifest, a CI pipeline, a config file — and get JSON. Multi-document files separated by --- become a JSON array, anchors and aliases are expanded, and YAML-only types such as dates are converted to the nearest JSON equivalent. Syntax errors are reported with a line number.

✓ Runs in your browser — nothing uploaded Free, no sign-upNo watermark

How to use the YAML to JSON

  1. Paste the YAML into the input box.
  2. Leave multi-document reading on for Kubernetes manifests and similar files.
  3. Read the JSON output, or the error with its line number if the YAML is malformed.
  4. Copy or download the result.

YAML is a superset of JSON

Every valid JSON document is also valid YAML, so conversion in this direction almost always succeeds. What YAML adds is comments, multi-line strings, anchors, explicit type tags and indentation instead of braces — none of which JSON can express. That mismatch is where the interesting cases live.

YAML featureWhat happens in JSON
Comments (# …)Dropped — JSON has no comments
Anchors &base / aliases *baseExpanded, so the shared block is repeated in full
Merge keys <<: *baseMerged into the mapping
Dates (2026-09-23)Converted to an ISO 8601 string
Multi-line blocks (| and >)Become ordinary strings with the right newlines
Non-string keysConverted to their string form

The errors you will actually hit

Three mistakes cause most YAML failures. First, tabs: YAML forbids them for indentation, and an editor that inserts a tab produces an error that looks nothing like the cause. Second, a missing space after the colonkey:value is a single scalar, while key: value is a mapping. Third, inconsistent indentation within a block, which silently changes the nesting rather than failing. The error message here includes the line number reported by the parser, which is where to start looking.

The Norway problem

In the older YAML 1.1 rules, the unquoted words y, n, yes, no, on and off are booleans — so a country list containing NO for Norway parses as false. YAML 1.2 narrowed this to true/false, but many tools still follow the old behaviour. Version numbers behave badly too: version: 1.20 is the number 1.2, and 1.2.3 is a string. Quote anything that must stay text.

Multi-document files

A single file can hold several documents separated by ---, which is how a Kubernetes deployment, service and ingress usually travel together. With multi-document reading on you get a JSON array with one element per document; with it off only the first is converted. JSON has no equivalent separator, so the array is the closest representation.

Round-tripping

Converting YAML to JSON and back will not reproduce your original file: comments, anchor structure, key order preferences and block-scalar styles are all lost. Convert in this direction to feed a tool that only speaks JSON, not to reformat a config file you intend to keep editing.

Frequently asked questions

Are comments preserved?

No. JSON has no comment syntax, so every # comment is dropped. Keep the YAML as the source of truth if comments matter.

What happens to anchors and aliases?

They are expanded, so the shared block appears in full at each place it was referenced. Merge keys are resolved into the mapping.

Why does my YAML fail to parse?

Usually a tab used for indentation, a missing space after a colon, or inconsistent indentation. The error message gives the line number.

Can it handle multiple documents in one file?

Yes. Documents separated by --- become elements of a JSON array when multi-document reading is on.

Privacy

This tool runs entirely inside your browser using WebAssembly and the Canvas/File APIs. Your files are never uploaded to ToolFlint or any third party; you can verify this in your browser's network tab or by switching to airplane mode after the page loads. Read how we process files.

Last updated 2026-09-23.