Skip to content

JSON to YAML Converter

Convert JSON to YAML for Kubernetes, Docker Compose or CI files, with safe quoting for older YAML 1.1 parsers and your choice of indent. Runs in your browser.

Runs in your browser

Everything happens on your device: nothing you paste or type is sent to our server or stored. A share link holds your settings, and your input only if you choose to include it.

On: "key:" then " - item" (Kubernetes, Docker Compose). Off: "- item" lines up with the key, as in the YAML specification’s examples. Both mean the same.

Older parsers (YAML 1.1) read unquoted no, yes, on, off, 0755 and 1:20 as booleans and numbers. Quoting them keeps them strings everywhere.

More options

Folding splits long strings over several lines without changing their value.

211 characters · 212 bytes (UTF-8) · limit 5 MB

Output: 174 characters.

  • Warning: 2 strings were quoted (such as "no" or "0755") because a YAML 1.1 parser would read them unquoted as a boolean, a number or a date.
Input size (bytes)
212
Output size (bytes)
175

Method: JSON, RFC 8259 → YAML 1.2.2 · yaml 2.9.1

Off by default. When on, your input is packed into the part of the link after “#”, which browsers never send to any server; anyone you give the link to will see it.

How it works

Your JSON is first checked with the same strict parser as our JSON formatter, so a mistake shows its line and column, and whole numbers of any length are kept digit for digit. Each object becomes a YAML mapping and each array a sequence, in the original key order. Strings that span several lines are written as literal blocks (a line with |- followed by the indented text), which keeps every line break.

The YAML is written by the open-source yaml library (version 2.9.1) following YAML 1.2.2. A string is quoted only when it would otherwise be read as something else: an empty string, 0755 or 1e3 (numbers in YAML 1.2), or text starting with a character YAML reserves. With the YAML 1.1 option on, strings such as no, on, yes and 1:20, which older parsers read as booleans or numbers, are quoted too, so every parser agrees.

You can choose 2 or 4 spaces, lists indented under their key or level with it, and quotes on every string. The library loads into your browser the first time you convert, and nothing you paste is uploaded.

Standards this tool follows

JSON to YAML: Write Config Files Every YAML Parser Reads the Same Way

By FindMySum · Last reviewed

This JSON to YAML converter rewrites JSON as clean, readable YAML for configuration files: Kubernetes manifests, Docker Compose files, GitHub Actions and Ansible playbooks. Paste JSON above and the YAML appears as you type. It is converted in your browser, so API keys and passwords that end up in config stay on your device.

Why convert JSON to YAML

The two formats hold the same data, and every JSON document is already valid YAML. YAML is easier to read and edit by hand: no braces or quotes around every key, and comments are allowed. That is why tools that people configure by hand prefer it, while APIs and programs exchange JSON. A typical case is copying an API response, or the output of kubectl get -o json, into a file a person will maintain.

How to use it

  1. Paste the JSON. If it has a mistake, the error message shows where.
  2. Pick the indentation your project uses; 2 spaces is the most common.
  3. Choose whether lists sit under their key (the Kubernetes style) or level with it.
  4. Leave the YAML 1.1 quoting on unless you know every program that reads the file follows YAML 1.2.
  5. Copy or download the YAML.

A worked example

{"app": "shop", "replicas": 2, "debug": "off", "ports": [80, 443], "motd": "Hello\nWorld"}

becomes:

app: shop
replicas: 2
debug: "off"
ports:
  - 80
  - 443
motd: |-
  Hello
  World

The number 2 stays a number and the ports a list. The string "off" is quoted because a YAML 1.1 parser would read a bare off as false. The two-line message becomes a literal block, where |- means "keep the line breaks, no final newline".

Common mistakes

Assuming YAML is whitespace-forgiving. Indentation decides structure. When you edit the output, keep each level aligned and use spaces, never tabs.

Removing "unnecessary" quotes. A quote around "0755", "no" or "1.10" is there for a reason: without it the value changes type, and a version number 1.10 becomes the float 1.1.

Pasting JavaScript instead of JSON. Single quotes, unquoted keys and trailing commas are errors, and the message shows where. The JSON formatter with its JSONC option removes comments and trailing commas for you.

To check how a parser reads YAML you already have, use the YAML to JSON converter.

Sources

Frequently Asked Questions

Why are some of my strings in quotes and others not?

YAML needs quotes only where a plain value would change meaning. "0755" without quotes is the number 755, an empty value is null, and in older YAML 1.1 parsers no is false. Everything else is written plainly, which is how people usually write YAML by hand. Choose "always" quoting if your team prefers it.

Is the YAML output valid for Kubernetes and Docker Compose?

Yes, it is standard YAML that both read. Parsers differ in how many YAML 1.1 habits they keep, such as reading a bare yes or on as true, which is why quoting 1.1 look-alikes is on by default. The converter doesn't check whether the fields themselves are valid for those tools.

Can I convert the YAML back to the same JSON?

Yes. The YAML to JSON converter reads the output back to the same values, under both YAML 1.2 and 1.1 rules; this round trip is part of our tests. Only the layout of the JSON, such as spacing, may differ from your original.

Why didn't my comments carry over?

JSON has no comments, so there are none to convert. Add them to the YAML afterwards with a # at the start of a line; YAML ignores everything after it.

Spotted a wrong result or a bug? Report a problem (the link sends the page address only, never what you entered).

May we count your visits with Invoker Analytics? It keeps a random visitor number in your browser. Your calculator inputs are never sent. Privacy policy