Formatters

Convert JSON to YAML

JSON to YAML converter dumps the JSON you paste as a YAML document with two-space indentation, for configs that read better in YAML or pipelines that require it. Developers use it when porting JSON config into docker-compose, CI definitions, and other YAML-first tooling. Strings that YAML would otherwise read as another type, such as 1.0 or true, are quoted automatically, null values print as null, and nested objects and arrays become indented blocks and dash lists.

How to use JSON to YAML

  1. Open JSON to YAML in the Toolbox101 app.
  2. Paste valid JSON into the JSON box; a config object or API response works.
  3. Read the YAML in the Output box, indented two spaces per level, as soon as the JSON parses.
  4. Strings that would change type in YAML, such as the version "1.0", come out quoted, and null values print as null.
  5. Click Copy to put the YAML on your clipboard, ready for a docker-compose or CI file.

Worked example

JSON to YAML returns the output below for this input.

Input

{"name":"toolbox101","version":"1.0","enabled":true,"replicas":3,"ports":[8080,9090],"env":{"NODE_ENV":"production"},"empty":null}

Output

name: toolbox101
version: '1.0'
enabled: true
replicas: 3
ports:
  - 8080
  - 9090
env:
  NODE_ENV: production
empty: null

Check it yourself: open JSON to YAML and enter the same input.

Frequently asked questions

Why does my string 1.0 come out quoted in the YAML?

A bare 1.0 would be read back as a number, and true or 2024-01-02 would change type too, so the dumper quotes any string that YAML would otherwise parse as something else. That keeps round-trips faithful: parse the YAML back and you get the original JSON values.

Why is the YAML indented with two spaces?

Two spaces per nesting level is the default used on this page. Arrays indent their dash items two spaces under the key, as the example shows with ports, and nested objects like env push each deeper key in by two more spaces.

How are null and empty values written?

A JSON null becomes an explicit null after the key, as in empty: null, rather than dropping the key. Empty strings stay as quoted empty strings, and empty arrays print as []. Nothing is ever silently removed from the document.

Is this the reverse of the YAML to JSON tool?

Yes. The two pages cover the same config workflow in both directions: this page serializes JSON as YAML, and the YAML to JSON page parses YAML back into indented JSON. YAML anchors cannot be generated here, but aliases in source YAML resolve when you convert it the other way.

Does it keep very large numbers exact?

No. This direction goes through JavaScript numbers, so an integer beyond 2^53 (9007199254740992) loses its low digits. If a value like an id has to survive exactly, keep it as a string in the JSON. The JSON Formatter and JSON to CSV tools do keep large numbers exactly as written.

Use JSON to YAML now

Runs in your browser. Nothing you type is uploaded.