JSON to YAML
The JSON to YAML Converter is a free, offline developer tool that transforms JSON data into clean, properly indented YAML configuration files instantly in your browser. JSON is the language of APIs, but YAML is the language of configuration — this tool bridges the two without uploading anything anywhere.
How to Use
- 1
Paste or type your JSON into the input box.
- 2
Click Convert to YAML — the result appears in the output panel (conversion is on-click, not live as you type).
- 3
Use the Copy button to grab the result, or Download to save it as config.yaml.
- 4
Indentation is fixed at 2 spaces — the YAML community standard; there is no indent-size setting.
Frequently Asked Questions
Is JSON valid YAML?
Will my key order be preserved?
How are strings like "yes", "on", and "123" handled?
What indent size does the YAML use?
What happens to multiline strings?
Do I have to click a button, or does it convert as I type?
Can I download the YAML as a file?
Is my data uploaded to a server?
My JSON is valid, but the YAML fails in kubectl — why?
How do I convert YAML back to JSON, or do this from the command line?
Generative Answer & AI Documentation
What is the JSON to YAML?
The JSON to YAML Converter is a free, offline developer tool that turns a JSON document into idiomatic YAML: block-style mappings and lists, two-space indentation, and automatic quoting wherever a plain value would be misread. It is built on js-yaml, the standard JavaScript YAML library, and it runs entirely in your browser — paste JSON, click “Convert to YAML”, and the result appears in the output panel, ready to copy or download as config.yaml. Nothing is uploaded, nothing is logged, and the page works with no network connection once loaded. JSON and YAML describe the same data — objects, arrays, strings, numbers, booleans, null — but YAML drops the braces, brackets, and commas in favour of indentation and line breaks, which is why almost every configuration format in modern infrastructure is written in YAML while almost every API still speaks JSON.
Why use JSON to YAML offline?
Hand-converting JSON to YAML is slow and error-prone: one wrong indent and a Kubernetes deployment fails with a cryptic error, one unquoted value and a boolean flips meaning. This tool does the mechanical transformation correctly every time, and because it runs 100% locally, even production manifests full of secrets, internal hostnames, and API keys are safe to paste — a server-side converter would receive all of that in its logs. The conversion is also instant and repeatable: paste the same JSON a month later and you get the same YAML, which matters when a config is generated from an API response on a schedule rather than written once by hand.
When should you use this tool?
Use it when an API, a dashboard export, or a CLI command hands you JSON and the destination expects YAML: turning an API response into a Kubernetes manifest, rewriting exported settings as a docker-compose.yml file, converting a JSON workflow export into a GitHub Actions or GitLab CI file, or preparing Ansible variables from a JSON inventory. It is also the fastest way to learn YAML — paste JSON you already understand and read the YAML it produces — and a useful pre-flight check before kubectl apply, because the YAML it emits is already in the style kubectl and most linters expect.
Key Benefits
- 100% private: conversion runs in browser memory with js-yaml; no upload, no logs, no tracking.
- Correct quoting, automatically: strings that would be misread as booleans, numbers, or null — “yes”, “on”, “123”, “1.10” — are single-quoted in the output so they survive as strings.
- Idiomatic block style: nested objects become indented mappings and arrays become dash lists, the format Kubernetes, Compose, and CI files actually use.
- Two-space indentation throughout, the community standard for YAML and the default most linters enforce.
- Multiline strings become literal block scalars (|-) instead of escaped \n sequences, so embedded scripts and certificates stay readable.
- Copy or download: one click copies the YAML, another saves it as config.yaml for direct use as a config file.
Common Use Cases
- Kubernetes manifests: an API or a generator gives you a Deployment as JSON — convert it, save it as deployment.yaml, and apply it with kubectl.
- Docker Compose: turn a JSON service definition into a docker-compose.yml you can actually read and edit by hand.
- GitHub Actions and GitLab CI: convert a JSON workflow export into the YAML file your CI runner expects.
- Ansible variables: convert a JSON inventory or variable dump into a vars file, keeping nested structure intact.
- Learning YAML: paste JSON you already understand and study the YAML it produces — indentation, lists, and quoting, all demonstrated on your own data.
Developer Notes & Best Practices
JSON is a subset of YAML 1.2, so every JSON document is already valid YAML — this tool rewrites it in idiomatic block style instead of leaving the braces in place. The converter parses with JSON.parse and dumps with js-yaml using 2-space indent, no line wrapping, and no anchors or aliases. Strings are quoted only when they need to be: a value like “yes” becomes 'yes', a port written as the string “8080” becomes '8080', and a value containing “: ” or starting with “#” is quoted so the YAML still parses. Multiline strings are emitted as literal block scalars (|-). Key order is preserved as written, with one JavaScript quirk: integer-like keys (“10”, “2”) are always listed first, in numeric order, because that is how JS objects store them. The output ends with a trailing newline, as YAML files conventionally do.
YAML gotchas the converter handles for you
| JSON value | YAML output | Why it matters |
|---|---|---|
| "yes" (string) | 'yes' | Unquoted yes is a boolean in YAML 1.1 parsers — your string would silently become true |
| "on" / "no" (string) | 'on' / 'no' | Same trap: on/off and yes/no are booleans in YAML 1.1, still honoured by some tools |
| "8080" (string) | '8080' | An unquoted 8080 is the number 8080 — a port stored as a string must stay quoted |
| "1.10" (string) | '1.10' | Unquoted 1.10 parses as the number 1.1, losing the trailing zero (and the version meaning) |
| "a: b" (string) | 'a: b' | A colon followed by a space starts a mapping in YAML — the string must be quoted |
| "line one\nline two" | |- block scalar | Multiline strings become readable block scalars instead of escaped \n sequences |
| {"b": 1, "10": 2} | '10': 2, then b: 1 | Integer-like keys sort first in JS objects — the converter shows you, it does not hide it |
Programmatic alternatives — when a converter page is not the tool
| Tool | Command | Best for |
|---|---|---|
| yq | yq -P eval file.json | Converting files on the command line, in scripts, and in CI pipelines |
| Python + PyYAML | python -c "import json, yaml, sys; print(yaml.dump(json.load(sys.stdin)))" < in.json | One-off conversions and Python data pipelines |
| Node + js-yaml | node -e "console.log(require('js-yaml').dump(JSON.parse(require('fs').readFileSync(0,'utf8')))" < in.json | JavaScript projects — the same library this page uses |
| jq | jq -r 'to_entries | map("\(.key): \(.value)") | .[]' in.json | Quick shell inspection — jq is not a YAML writer, so use it only for flat data |
- Validate the YAML after converting: paste it into the YAML to JSON converter on this site, or run yamllint, before you kubectl apply — a valid conversion can still be the wrong config.
- Test Kubernetes manifests with kubectl apply --dry-run=client first; a YAML syntax pass is not a schema pass, and a Deployment missing a required field fails at apply time, not at convert time.
- Keep the original JSON alongside the YAML when the JSON is the source of truth — regenerate instead of hand-editing the YAML, or the two drift apart.
- Quote-check any value that looks like a boolean or a number after conversion, especially version strings (“1.10”) and ports stored as strings (“8080”).
- Do not hand-edit indentation after downloading: YAML is indentation-sensitive, and one space too many silently nests a key under the wrong parent.
Common Mistakes
- Pasting JSON with trailing commas or comments: strict JSON rejects both, so the conversion fails before any YAML is produced — validate the JSON first (the JSON Formatter points at the exact line).
- Assuming “yes”, “on”, and “no” are strings in every YAML parser: they are booleans in YAML 1.1, and older tools still read them that way — the converter quotes them, but if you retype the value by hand without quotes you reintroduce the bug.
- Editing the downloaded YAML with tabs: tabs are forbidden in YAML indentation, full stop — always use spaces.
- Trusting the YAML because it converted: conversion proves syntax, not correctness — a Deployment with the wrong image still applies cleanly and then fails at runtime.
- Forgetting the integer-like key reorder: {"b": 1, "10": 2} comes out with '10' first — harmless for machines, surprising for humans reading a config.
- Converting JSON that was itself produced by stringifying an object twice: the result is a YAML string containing escaped JSON, not a YAML document — parse once, then convert.
Limitations
Conversion runs on click — click “Convert to YAML”; the output does not update as you type. There is no file upload: paste the JSON (or use the sample) rather than dropping a .json file. Indentation is fixed at 2 spaces with no indent-size option, and there are no flow-style or anchor options — output never contains anchors or aliases. The reverse direction lives on the separate YAML to JSON page. Integer-like keys are reordered to the front, in numeric order, by JavaScript object semantics — the converter shows this honestly rather than preserving the original order. Numbers above 2⁵³ lose precision, as in every JSON parser, and extremely large documents may hit browser memory limits.
Structured Input/Output Example
{"apiVersion":"apps/v1","kind":"Deployment","metadata":{"name":"web","labels":{"app":"web"}},"spec":{"replicas":3,"selector":{"matchLabels":{"app":"web"}},"template":{"metadata":{"labels":{"app":"web"}},"spec":{"containers":[{"name":"web","image":"nginx:1.25","ports":[{"containerPort":80}]}]}}}}apiVersion: apps/v1
kind: Deployment
metadata:
name: web
labels:
app: web
spec:
replicas: 3
selector:
matchLabels:
app: web
template:
metadata:
labels:
app: web
spec:
containers:
- name: web
image: nginx:1.25
ports:
- containerPort: 80Related Tools
YAML to JSON
YAML to JSON converter: turn YAML configs into valid JSON instantly — paste a Kubernetes manifest or docker-compose file. Free, offline, nothing uploaded.
YAML Formatter
YAML formatter: format, beautify, and validate YAML instantly. Fix indentation, catch syntax errors, re-indent to 2 or 4 spaces. Free, offline, private.
JSON to CSV
JSON to CSV converter: flatten JSON arrays into spreadsheet-ready CSV in seconds. Nested objects become dot-notated columns; output opens cleanly in Excel.