JSON to YAML

Convert JSON to YAML and YAML back to JSON, with 2 or 4-space indents. Quotes values like yes, no and 08 so they are not misread.

Runs in your browserNo sign-upWorks offline
Ctrl+Enter to run
Input121 characters
Output
✓ ReadySample content shown

What the JSON to YAML does

JSON to YAML converts in both directions. Turn a JSON object into YAML for a Kubernetes manifest, a docker-compose file, a GitHub Actions workflow or app config, or turn YAML into JSON for an API or JavaScript code. Values that could be misread in YAML, such as yes, no, on, 08 or numbers stored as text, are put in quotes, so the result means exactly what the original did.

How to use it

  1. Choose JSON to YAML or YAML to JSON.
  2. Paste the input on the left.
  3. Choose the indent.
  4. Copy or download the result.

Example

The sample service config becomes YAML with nested env settings and a list of ports. The PORT value, a string "4141" in JSON, stays in quotes in YAML so it is not turned into a number, while replicas: 2 stays a number and healthCheck stays null.

JSON and YAML compared

YAML is easier for people to read and allows comments, so it is popular for configuration. JSON is stricter and easier for programs to exchange, so it is used by most APIs. Every JSON document is valid YAML, but YAML has extra features, such as anchors and multiple documents, that JSON cannot hold.

When converting YAML to JSON, comments are dropped because JSON has no comments.

Questions people ask

Is my code or data uploaded?

No. Everything runs in your browser, so config files, queries, logs and keys stay on your device. That makes it safe to use with work data.

Why are some strings quoted in the YAML?

Without quotes, YAML readers would turn values like "yes", "08" or "4141" into true/false or numbers. Quoting keeps them as text.

Is key order kept?

Yes, keys appear in the same order as in the input.

Can it read YAML with errors?

No. Problems are reported with the line and column, as in the YAML Validator.

Related tools