Skip to content

YAML to JSON Converter

Convert YAML to JSON and JSON back to YAML, with validation and clear error messages.

Converted in your browser — config files with secrets never leave your device.

How do you convert YAML to JSON?

Parse the YAML into maps, lists and scalars, then re-serialise that structure as JSON. Indentation becomes nesting, sequences become arrays and key-value pairs become object properties. YAML 1.2 is a superset of JSON, so JSON converts to YAML losslessly, but YAML comments and anchors cannot survive the trip.

Understanding your result

YAML expresses structure through indentation, which makes it pleasant to edit but unforgiving: a single stray space or a tab character instead of spaces will break a file. Conversion is not perfectly lossless in either direction — YAML comments and anchors have no JSON equivalent and are dropped, and JSON cannot represent YAML’s date or multi-document syntax. This tool parses with the JSON-compatible schema, so values are read the same way JSON would read them, which avoids YAML’s classic surprise of turning the word "no" into a boolean false.

Formula and method

YAML is a superset of JSON, so every valid JSON document is already valid YAML. Conversion parses the source into an in-memory structure of maps, lists and scalars, then re-serialises that structure in the target syntax.

Assumptions and limitations

Converts the first YAML document only, so files separated by --- markers must be split first. Comments and anchors have no JSON equivalent and are dropped. Values are read with the JSON-compatible schema, so YAML-specific types such as dates are returned as strings.

Worked example

A short config with a name, a version, a two-item feature list and a nested server block converts to JSON with 6 keys at a nesting depth of 2 — the list becoming a JSON array and the nested block a nested object.

How to use this tool

  1. Pick the direction you want to convert in.
  2. Paste your YAML or JSON into the box.
  3. Choose an indent size, or tick minify for compact JSON.
  4. Copy or download the converted output.

Common mistakes to avoid

  • Indenting YAML with tab characters — the specification requires spaces.
  • Expecting comments to survive the trip to JSON; they cannot.
  • Leaving a trailing comma in JSON, which YAML tolerates but JSON does not.
  • Forgetting to quote strings that look like booleans, such as yes, no, on and off.

About the YAML to JSON Converter

This converter moves data between YAML and JSON in both directions using the js-yaml parser bundled with the page. It validates as it goes, reports the precise reason a document failed to parse, and reports the key count and nesting depth so you can sanity-check the result.

Who should use this tool

Developers and DevOps engineers working with Kubernetes manifests, CI pipelines, Docker Compose files and API payloads.

Benefits

  • Bidirectional — YAML to JSON and JSON back to YAML.
  • Reports the specific parse error instead of just failing.
  • Choose 2- or 4-space indentation, or minify the JSON.
  • Config files containing credentials never leave your browser.

Practical use cases

  • Converting a Kubernetes or Docker Compose YAML file into JSON for an API call.
  • Turning a JSON API response into readable YAML for a config file.
  • Checking whether a YAML file is valid before committing it.
  • Migrating settings between tools that expect different formats.

Explore all Developer Tools tools

Frequently asked questions

Is YAML really a superset of JSON?

Yes, since YAML 1.2. Any valid JSON document is also valid YAML, which is why converting JSON to YAML always succeeds while the reverse can fail on YAML-only features.

What happens to my comments?

They are dropped. JSON has no comment syntax, so there is nowhere for them to go. Keep the original YAML if the comments matter.

Are my files uploaded anywhere?

No. The parser is bundled with the page and runs in your browser, so a manifest containing secrets or internal hostnames never leaves your device.

Why does my YAML fail to parse?

Almost always indentation: a tab character, a missing space after a colon, or inconsistent nesting. The error message names the line so you can jump straight to it.

Can it handle multi-document YAML?

It converts the first document. Files separated by --- markers should be split and converted one document at a time, since JSON has no multi-document concept.

Share this tool

Free to use — copy the link, share it anywhere, or add the tool to your own website.

Embed this tool on your site (free)

Copy this code and paste it into any web page — it stays free and always up to date: