JSON to YAML Converter
Brackets to indentation. The Kubernetes way.
What this does
Paste JSON, get YAML. Two-space block style, keys in the order you wrote them, and no line wrapping. The kind of YAML humans actually want to read.
Here's a ConfigMap that starts life as JSON:
{
"kind": "ConfigMap",
"metadata": {
"name": "app"
},
"data": {
"COUNTRY": "NO",
"DEBUG": "on",
"MODE": "0755",
"PORT": "8080",
"TIMEOUT": 30,
"RETRY": true,
"TAGS": []
}
} And the YAML you get:
kind: ConfigMap
metadata:
name: app
data:
COUNTRY: 'NO'
DEBUG: 'on'
MODE: '0755'
PORT: '8080'
TIMEOUT: 30
RETRY: true
TAGS: [] Every string a YAML reader could mistake for something else got single quotes. To a YAML 1.1 parser, NO and on are booleans and 0755 is an octal number. 8080 would be an integer anywhere. The real number and the real boolean stay bare, because that's what they are.
Common use cases
Turning kubectl get -o json output or an API response into a manifest you can edit and commit.
Writing CI and deploy configs. GitHub Actions, GitLab CI and Docker Compose all want YAML, and sometimes the data starts out as JSON from a script.
Making a config people can maintain. Less punctuation, room for comments, and nobody hunting for a missing closing brace.
Things to know
YAML 1.2 is a superset of JSON, so technically your JSON was already valid YAML. But nobody writes YAML that looks like JSON. This tool produces the clean indented style people expect.
Strings with line breaks become block scalars: usually | or |-, depending on whether the string ends with a newline. Strings containing a tab, a byte order mark or a Unicode line separator get double quotes with escapes instead. PyYAML rejects raw tabs in plain values, and 1.1 readers treat those separators as line breaks.
Numbers go through JavaScript first, so 1.0 comes out as 1. Numbers that JavaScript prints with an exponent, like 1e21, get written as 1.e+21, which still reads as a float under YAML 1.1 rules.
The quoting only protects what the tool writes. Edit the file later, type country: NO without quotes, and a YAML 1.1 reader is back to reading false.
Privacy
Conversion runs entirely in your browser. Your configs, secrets and all, stay local.
Questions
Why are some of my strings in quotes?
Because without quotes they'd stop being strings. The tool single-quotes values like 'NO', 'on', 'y', '0755', '22:22', '2024-01-01', 'null' and '1.10'. Left bare, a YAML 1.1 reader turns those into booleans, an octal number, a base-60 integer, a date, a null and a float. Ordinary strings stay unquoted.
Why does YAML 1.1 still matter?
Plenty of tools never moved to YAML 1.2. PyYAML, and everything built on it like Ansible, still reads yes, no, on and off as booleans. That's the Norway problem: the country code NO quietly turns into false. Kubernetes manifests go through a Go parser with the same 1.1 habits. Quoting costs two characters and works everywhere.
Can I get flow style or 4-space indentation?
No. Output is always block style with two-space indentation, the style you'll see in the Kubernetes and Docker docs. Empty objects and arrays are the exception: they come out as {} and [], since there's nothing to indent.
Does it keep my key order?
Yes, with one JavaScript quirk. Keys that look like whole numbers, like "10", jump to the front. JSON.parse orders them that way before the converter ever sees them.
Will long strings get wrapped?
No. Line wrapping is off, so a 300-character description stays on one line. Some converters fold long strings at 80 columns, which is valid YAML and still annoys anyone reading the diff.