1. Home
  2. Developer tools
  3. YAML ⇄ JSON

YAML ⇄ JSON

Switch configuration files between YAML and JSON, with line-accurate errors.

Free, no sign-up. Runs in your browser: nothing is uploaded.

Free workspace included. Docs, spreadsheets, notes and tasks that save on your device. No sign-up.Take a look

How to use YAML ⇄ JSON

  1. Paste YAML or JSON.
  2. Choose the direction.
  3. Copy or download.

Features

  • Both directions
  • Multi-document YAML
  • Indentation options

Supported formats

Input

  • Pasted YAML
  • Pasted JSON

You get

  • JSON
  • YAML

Private by design

Everything you enter is processed by your browser on this device. Nothing is sent to openWorkstand or anyone else, so the YAML ⇄ JSON is safe for private and work data. After you have used it once while online, it also works without an internet connection. How local processing works

Good to know

  • Comments are lost when converting YAML to JSON, because JSON has no comments, and anchors are expanded into full copies.

Guide

Converting YAML to JSON, and the type traps to watch for

YAML and JSON describe the same kinds of data: objects, lists, strings, numbers, true/false and null. YAML is easier to write by hand, which is why Docker Compose, Kubernetes, GitHub Actions, Ansible and many apps use it for configuration. JSON is what most APIs and programs expect. This converter goes both ways in your browser and shows exactly how YAML interprets your values.

Converting

  1. Choose the direction: YAML → JSON or JSON → YAML.
  2. Paste your data; the result appears as you type.
  3. Choose 2 or 4 spaces of indentation.
  4. Copy the result or download it as data.json or data.yaml.
  5. Use the swap button to feed the result back in and convert the other way.

Example

service: invoices
port: 8080
debug: false
owners:
  - ada
  - grace

becomes

{
  "service": "invoices",
  "port": 8080,
  "debug": false,
  "owners": ["ada", "grace"]
}

(The converter puts each list item on its own line; it’s shortened here.)

YAML type traps

YAML guesses types from how values look. That’s convenient until it guesses wrong. This converter follows YAML 1.2, the current version; some tools (PyYAML, older Ruby and Go libraries) still follow YAML 1.1 and guess even more:

You write You might expect This converter gives Older YAML 1.1 tools Fix
version: 1.10 “1.10” the number 1.1 the number 1.1 version: "1.10"
zip: 01234 “01234” the number 1234 a number, possibly octal (668) zip: "01234"
country: NO (Norway) “NO” “NO” false country: "NO"
time: 12:30 “12:30” “12:30” the number 750 (12 × 60 + 30) time: "12:30"

Converting to JSON is a quick way to see what a YAML file really means. If a value in the JSON isn’t what you meant, quote it in the YAML. Quoting is also the safest choice when the same file is read by several tools.

Other differences

  • Comments (# like this) exist in YAML but not in JSON, so they’re dropped.
  • Several documents in one file, separated by ---, become a JSON array of documents.
  • Anchors and aliases (&default, *default) are expanded, so repeated sections appear in full in the JSON.
  • Indentation is meaningful in YAML. Use spaces, never tabs.
  • Multi-line strings written with | (keep line breaks) or > (fold into one line) become ordinary JSON strings with \n where line breaks are kept.

JSON to YAML

Converting JSON to YAML is handy for writing configuration from an API response or turning a JSON example into a readable config file. Keys keep their order, long lines are wrapped at about 120 characters, and strings are quoted only where YAML needs it.

When parsing fails

Common causes are tabs in the indentation, inconsistent indentation inside a list, and an unquoted value with a colon and a space, such as title: Part 1: Intro. Quote the value: title: "Part 1: Intro". The error message from the parser points to the problem.

Privacy

Files are converted in your browser, so configuration with hostnames or internal settings isn’t uploaded. Still, avoid pasting real passwords and keys into any tool you don’t need to.

Who converts YAML and JSON

  • DevOps engineers work with Kubernetes, Docker Compose and CI configuration files.
  • Developers convert configuration for tools that expect JSON.
  • API designers switch OpenAPI specifications between YAML and JSON.
  • Students learn both formats side by side.

A complete example: checking a CI configuration

A CI pipeline fails with a type error on a version number:

  1. Paste the YAML and look at the JSON output.
  2. A value like python-version: 3.10 appears as the number 3.1.
  3. Quote it in the YAML, python-version: "3.10", and convert again to confirm.

Tips

  • Quote values that look like numbers but aren’t, such as versions and ZIP codes.
  • Keep the YAML as the source of truth if it has comments.
  • JSON Formatter to check and tidy the JSON, with line-and-column errors.
  • CSV to JSON when your data is a table rather than a config file.
  • Diff Checker to compare two configuration files.

Checked against the current version of the YAML ⇄ JSON on .

Troubleshooting

The download did not start

Look for your browser’s download bar or icon. Some browsers ask once before a site may download files; allow it and click the button again.

Frequently asked questions

Why did my version 1.10 become 1.1?

YAML reads unquoted 1.10 as a number, and as a number it equals 1.1. Put quotes around values that must stay text, such as version: "1.10". Converting to JSON is a quick way to spot these surprises.

Are YAML comments kept?

No. JSON has no comments, so they're dropped when converting to JSON, and a round trip back to YAML won't restore them. Keep the original YAML file if the comments matter.

What happens to a file with several YAML documents?

Documents separated by --- become a JSON array, one element per document. That's common in Kubernetes manifests that define several resources in one file.

Why does my YAML fail to parse?

The most common causes are tabs used for indentation (YAML allows only spaces), inconsistent indentation within a list or map, and an unquoted value containing a colon followed by a space. The error message points to the problem.

Keep working with the result

After you download, choose “Save to Workstand” to keep the result in a folder on your computer, attach it to a project and create a follow-up task. It is saved by your browser, not uploaded.