JSON to YAML Converter

Paste JSON to get readable YAML for Docker Compose, Kubernetes, or CI config files. The JSON to YAML converter keeps key order and quotes values that would otherwise change type.

Updated
Runs in your browser. Your data is not uploaded.
Converts as you type for inputs up to 200 KB.

How to use the JSON to YAML Converter

  1. Paste JSON into the input box, or upload a .json file up to 5 MB.
  2. Choose an Indent of 2 or 4 spaces.
  3. Press Convert, then Copy the YAML or Download .yaml.

How it works

  • Keys stay in the order they appear in the JSON.
  • Output uses block style. Flow style is used only for empty arrays [] and empty objects {}.
  • Strings are quoted only when they need it: values YAML would read as another type (yes, no, on, off, null, true, or number-like text such as 007 or 1.0), and strings with leading or trailing spaces, : , #, or a special first character.
  • Strings with line breaks become | block scalars.
  • Big integers beyond 2^53 are kept exactly, because the JSON is read with a lossless parser.

Examples

Input:

{"server":{"port":8080,"hosts":["a.example.com","b.example.com"]},"debug":false}

Output:

server:
  port: 8080
  hosts:
    - a.example.com
    - b.example.com
debug: false

{"country":"no"} gives country: "no". The quotes stop YAML 1.1 tools from reading it as false.

JSON vs YAML

JSONYAML
StructureBraces and bracketsIndentation
CommentsNot allowedAllowed with #
QuotesRequired around strings and keysUsually optional
Typical useAPIs and data exchangeConfiguration files

Docker Compose, Kubernetes manifests, GitHub Actions workflows, and Ansible playbooks are all written in YAML. Converting from JSON is handy when an example or an API gives you JSON but the tool wants YAML.

Limitations

  • Input is limited to 5 MB.
  • Invalid JSON gives an error with the line and column.
  • JSON has no comments, so the YAML has none either. You can add # comments afterwards.
  • Anchors and aliases are never generated. Repeated data is written out in full.

Frequently asked questions

Is YAML a superset of JSON?

YAML 1.2 is designed so that valid JSON is also valid YAML. Converting to YAML's block style makes the file easier for people to read and edit.

Why are some values in quotes?

Words like "no" or numbers with leading zeros would change type in some YAML parsers. Quoting keeps them as text.

Can I add comments?

JSON has no comments, so the output has none. You can add # comments to the YAML afterwards.

Often used together with the JSON to YAML.