How to use the JSON to YAML converter
- Paste or drop JSON into the left pane. Invalid JSON is rejected with the exact line and column. For JSON with comments or trailing commas, run it through JSON Repair first.
- Indent: 2 spaces (the Kubernetes and Compose convention) or 4 spaces.
- Strings: Plain quotes only when necessary; Double or Single quotes every string value.
- Indent lists: on indents
- itemunder its key, the style most Kubernetes docs use. Off puts the dash at the same level as the key. Both are valid YAML. - YAML 1.1-safe quoting (on by default): also quotes strings like
yes,NOor2026-09-27that YAML 1.1 parsers would turn into booleans or dates. - Copy or Download the result as
output.yaml.
Example
{ "metadata": { "name": "web" }, "spec": { "replicas": 3, "containers": [{ "name": "web", "image": "nginx:1.27" }] } }
becomes
metadata:
name: web
spec:
replicas: 3
containers:
- name: web
image: nginx:1.27
How values are converted
| JSON | YAML output | Why |
|---|---|---|
"1.0", "123", "0755" |
"1.0", "123", "0755" |
Quoted so they stay strings, not numbers |
"true" |
"true" |
Quoted so it stays a string, not a boolean |
"#tag", "a: b" |
"#tag", "a: b" |
# starts a comment and : starts a mapping |
"" |
"" |
An empty plain value would mean null |
null |
null |
|
"a\nb" |
a |- literal block |
Multi-line strings stay readable |
Long strings are never folded onto several lines, so URLs, keys and base64 values stay on one line.
YAML 1.1 vs 1.2: the “Norway problem”
In YAML 1.1, a bare NO (the country code for Norway), yes, on and off are booleans, and 2026-09-27 is a date. YAML 1.2 treats all of them as strings. This tool writes YAML 1.2, and by default it also quotes whatever YAML 1.1 would reinterpret: {"country": "NO"} becomes country: "NO" and stays a string in PyYAML, go-yaml v2 and older Kubernetes tooling. Keys are covered too, so a key named n or y is quoted.
Turn YAML 1.1-safe quoting off only if every consumer speaks YAML 1.2 and you want the barest output.
Converting in code
# yq (mikefarah/yq v4)
yq -p=json -o=yaml '.' data.json > data.yaml
# Python — PyYAML (writes YAML 1.1)
import json, yaml
with open("data.json") as f:
print(yaml.safe_dump(json.load(f), sort_keys=False, allow_unicode=True))
// Node.js — the same "yaml" library this tool uses
import YAML from 'yaml';
console.log(YAML.stringify(JSON.parse(text)));
Going the other way? YAML to JSON converts and validates YAML. To tidy the JSON first, use the JSON Formatter.
Frequently asked questions
Is the output valid for Kubernetes, Docker Compose and GitHub Actions?
Yes. The converter writes standard YAML 1.2 block style — nested objects become indented keys and arrays become "- " list items — which kubectl, Docker Compose, GitHub Actions and OpenAPI tooling all read.
Why are some strings quoted and others not?
With the default Plain style, a string is quoted only when leaving it bare would change its meaning. "123", "true", "0755", "1.0" and "#tag" are quoted so they stay strings; ordinary text like nginx:1.27 is left plain.
My YAML consumer reads "yes" or "no" as a boolean. What should I do?
Older YAML 1.1 parsers (PyYAML, go-yaml v2, some Ruby libraries) treat yes, no, on, off and dates as special values. With "YAML 1.1-safe quoting" on, which is the default, any string a 1.1 parser would misread is written in double quotes, so the output means the same thing to every parser. Set Strings to Double or Single if you prefer every value quoted.
Are large integers preserved?
Yes. The JSON is parsed losslessly, so an ID like 9007199254740993 is written unchanged. Converters built on JSON.parse round it to 9007199254740992.
Is my JSON uploaded?
No. Parsing and YAML generation run in your browser, and nothing is uploaded.
Last updated