Shard Tools

JSON to YAML

Convert JSON into clean, readable YAML in your browser.

Maintained by Roshan.

Use JSON to YAML

Converts between YAML and JSON in this tab. The parser is fetched only when you convert, so the page stays light until you use it.

This parser follows YAML 1.2Only true and false are booleans. Older YAML 1.1 parsers also treated yes, no, on and off as booleans, which is why a country code of NO could silently become false. Quote any value whose literal text matters.

Explore developer and data tools

Find related browser-local tools for nearby tasks without starting another search.

Browse all developer and data tools

About JSON to YAML

Most people converting JSON to YAML are moving something into a configuration file, because that is where YAML lives: Kubernetes manifests, CI pipeline definitions, Docker Compose files, application settings. YAML earns its place there by being far easier to read and to comment than JSON, and it is a strict superset, so every valid JSON document is already valid YAML. That last fact makes this conversion sound trivial, and structurally it is. What is not trivial is producing YAML a human actually wants to maintain, which means block style rather than inline braces, sensible line handling for long strings, and quoting applied exactly where it is needed and nowhere else. Over-quoting produces noisy output; under-quoting produces a file that parses into the wrong values.

Work through the input

  1. The JSON is parsed first, so an error is reported precisely rather than producing partial output.
  2. The structure is emitted in block style: nested maps and sequences are indented rather than written inline, which is the form configuration files use.
  3. Long strings are not wrapped. YAML permits folding a long line across several, but the result is harder to diff and easy to break by hand, so lines are left intact however long.
  4. Anchors and aliases are disabled. When the same object appears twice, it is written out twice rather than referenced, because an unexpected alias in a configuration file is confusing to read and to edit.
  5. Strings that would otherwise be read back as something else are quoted automatically. A value of true, or 12345, or a date-like string is quoted so it survives as text.

When json to yaml is useful

Turning an API response into a config file

Convert, then add comments explaining each setting. The comments are the entire advantage YAML has over the JSON you started with.

Writing a Kubernetes manifest

Building the structure as JSON and converting is often quicker than getting the indentation right by hand, since YAML's meaning depends on whitespace.

Check the output

Questions about JSON to YAML

Is JSON already valid YAML?

Yes. YAML 1.2 is a superset of JSON, so any JSON document parses as YAML. Converting is about readability and the ability to add comments, not compatibility.

Why are some strings quoted and others not?

Quotes are added only where they change the meaning. A value of true or 12345 must be quoted to stay a string; ordinary words do not need it.

Can I add comments?

Not during conversion, because JSON cannot carry them. Add them to the YAML afterwards using the # character.

What is the Norway problem?

Under YAML 1.1, the country code NO was parsed as the boolean false. This tool follows YAML 1.2 where that no longer happens, but older parsers reading your file might still do it.

Is the data sent anywhere?

No. Parsing and emitting both happen in this tab, which matters since configuration files routinely contain hostnames and credentials.

Related tools

YAML to JSON Converter

Convert YAML to JSON or JSON to YAML in your browser. Handles multi-document files, follows YAML 1.2, and uploads nothing.

JSON Formatter and Validator

Format, minify, and validate JSON locally in your browser. Inspect keys, values, nesting depth, and root type without sending private API data to a server.

JSON to XML

Turn JSON into well-formed XML in your browser, with escaping and element naming handled correctly.

JSON to INI

Turn JSON into an INI configuration file in your browser, with objects becoming sections.

JSON to ENV

Turn a JSON object into .env format in your browser, with keys upper-cased and values quoted where a shell needs it.