Quick answer
A JSON-to-YAML converter rewrites JSON's brace-and-bracket structure as YAML's indentation-based block style: objects become mappings, arrays become - sequences, and scalars carry over. This tool uses 2-space indentation, quotes every string (which safely avoids YAML's type-coercion traps), and leaves numbers, booleans, and null unquoted — all in your browser, nothing uploaded. Paste JSON, click Convert to YAML, then copy or download.
How This Tool Converts JSON to YAML
- JSON objects become YAML mappings — each key-value pair is written as
key: valueon its own line. - JSON arrays become YAML sequences — each item is placed on its own line prefixed with
-. - Every string value is double-quoted in the output; keys are left unquoted. Quoting all strings is intentional — it stops YAML from re-reading a string like
noor1.10as a boolean or a number (see the Norway problem below). - Nested objects and arrays use 2-space indentation per level — the standard convention for YAML used in Docker Compose, Kubernetes, and GitHub Actions.
- Numbers, booleans (
true/false), andnullcarry over without quotes.
When to Use JSON to YAML
- When a Docker Compose file, Kubernetes manifest, or Helm chart values file requires YAML and you're starting from a JSON prototype or API response.
- When a CI/CD pipeline definition (GitHub Actions, GitLab CI, CircleCI) needs YAML input and your data is in JSON.
- When your application's config library reads YAML and you want to convert an existing JSON config without manually rewriting it.
Worked example
A small config object with a nested object, an array, and mixed value types:
Input JSON
{
"name": "web",
"replicas": 3,
"active": true,
"skills": ["JS", "Python"],
"address": { "city": "Boston" }
}
Output YAML
name: "web"
replicas: 3
active: true
skills:
- "JS"
- "Python"
address:
city: "Boston"
What happened
- Each top-level key became a mapping line; the object braces disappeared in favour of indentation.
- The
skillsarray became a two-item sequence, each on its own-line, indented two spaces under its key. - The nested
addressobject was indented one level (two spaces) beneath its key. "web","JS","Boston"are quoted because they are strings;replicas: 3andactive: trueare left unquoted because they are a number and a boolean.
Edge cases & gotchas
- The Norway problem. Unquoted, YAML 1.1 reads
no,off, andnasfalse, andyes,on,yastrue— so a country-code list containingNOsilently becomesfalse. This tool quotes every string ("no"), which sidesteps it entirely. - Version numbers and leading zeros. Unquoted
1.10parses as the float1.1(trailing zero lost), and08can throw as an invalid octal. Quoted, they stay the strings"1.10"and"08". - JSON is already valid YAML. YAML is a superset of JSON, so a parser will accept raw JSON — converting is about readable, idiomatic block style, not validity.
- Indentation is significant. Unlike JSON, YAML's structure is its indentation. If you hand-edit the output, keep the 2-space steps consistent — a stray space changes the meaning.
- Multi-line strings become YAML block scalars (
|), preserving their line breaks.
Frequently Asked Questions
Does this tool preserve JSON data?
Yes. It converts JSON structure to YAML while keeping the same keys and values.
Can I convert nested arrays and objects?
Yes. Nested JSON objects are represented using YAML indentation for readability.
Can I move back to JSON?
Yes. Use the YAML to JSON Converter to reverse the conversion, or paste directly into the JSON Formatter.
Are strings automatically quoted in the output?
Yes. Every string value is emitted with double quotes, while numbers, booleans, and null are left unquoted. Quoting all strings is deliberately safe — it prevents YAML from re-interpreting string values as other types. Keys are not quoted.
Why does quoting strings matter in YAML (the Norway problem)?
YAML 1.1 coerces several unquoted words into booleans — no, off, and n become false, while yes, on, and y become true. The classic example is a list of country codes where NO (Norway) silently turns into the boolean false. Unquoted version numbers like 1.10 also become the float 1.1, and values like 08 can error as an invalid octal. Because this converter quotes every string, values like "no", "1.10", and "08" stay strings and avoid all of these traps.
Isn't JSON already valid YAML?
Yes — YAML is a superset of JSON, so any valid JSON document is technically also valid YAML and most YAML parsers will accept it as-is. The reason to convert is readability and idiom: tools like Kubernetes, Docker Compose, and Ansible expect the indentation-based block style, not JSON's braces, and reviewers expect to see it that way in config files.
Does the YAML output use 2-space or 4-space indentation?
The output uses 2-space indentation, which is the most common convention for YAML files used in Docker Compose, Kubernetes, and GitHub Actions.