JSON to YAML Converter
Convert JSON to readable YAML in your browser. Nothing is uploaded. Useful for Kubernetes manifests, CI configs, and OpenAPI specs.
Your stuff stays yours. The conversion happens in this page's JavaScript. Nothing you paste here leaves your machine, and the tool keeps working with the network unplugged.
Paste any valid JSON and get YAML suitable for Kubernetes manifests, GitHub Actions workflows, docker-compose files, or OpenAPI specs. Output uses two-space indentation and avoids YAML references, so the result stays readable and portable.
How to use the JSON to YAML converter
- Paste your JSON into the JSON in box. It can be minified on one line or already indented; whitespace between tokens does not matter.
- Click Convert to YAML. The YAML appears in the YAML out box with keys in the same order as your JSON.
- If nothing appears and a message shows under the buttons, the JSON did not parse. The message comes from your browser's JSON parser and names the position of the first bad character.
- Click Copy result and paste the YAML into your file. Clear empties both boxes.
Why some values come out in quotes
YAML figures out types from how a value looks. 3 is a number, true is a boolean, and null or ~ means nothing at all. JSON is explicit about types, so when a JSON string happens to look like something else, the converter has to wrap it in quotes. Otherwise the YAML would load back as a different type.
The quoting is also cautious about older parsers. In YAML 1.1, which many tools still follow, words like yes, no, on, off, y, and n were booleans. The converter quotes all of them, so "on" becomes 'on' and still reads as a string everywhere. The same applies to keys, which is why a key named on or n appears as 'on': or 'n':.
Other strings that get quotes include ones that look like numbers or dates ('02134', '1.0', '2024-03-15'), the empty string (''), strings with leading or trailing spaces, and strings that start with YAML punctuation such as -, #, or =. Strings with a tab or other control character are written in double quotes with an escape, like "a\tb". Ordinary text, including accented letters, emoji, URLs, and image: nginx:1.27, is left plain.
Multi-line strings are written as block scalars. A string with line breaks and no trailing newline uses |-; one that ends with a newline uses |. A single-line string longer than about 120 characters is folded with >- over several lines, which any YAML parser joins back into the original single line.
A worked example
Here is a small CI workflow written as JSON:
{
"name": "build",
"on": ["push"],
"env": { "DEBUG": "false", "ZIP": "02134", "RETRIES": 3 },
"steps": [
{ "name": "Checkout", "uses": "actions/checkout@v4" },
{ "name": "Test", "run": "npm ci\nnpm test" }
],
"tags": []
}
Clicking Convert to YAML produces:
name: build
'on':
- push
env:
DEBUG: 'false'
ZIP: '02134'
RETRIES: 3
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Test
run: |-
npm ci
npm test
tags: []
The on key is quoted for the reason above. DEBUG and ZIP are quoted because they were strings in the JSON, while RETRIES stays a bare number. The two-line run command became a |- block, and the empty array stays in compact form as []. List items under a key are indented two spaces past that key, and the output ends with a newline.
Common problems and how to fix them
Large IDs change their last digits
The JSON is read with the browser's JSON parser, which stores numbers as 64-bit floating point. An integer above 9,007,199,254,740,991, such as a 20-digit order ID, is rounded before it reaches YAML: 12345678901234567890 comes out as 12345678901234567000. If the exact digits matter, make the value a string in the JSON first.
A key appears once when the JSON had it twice
Duplicate keys in one object are legal to parse but only the last one survives. {"a":1,"a":2} converts to a: 2 without a warning. Search your JSON for the key if a value seems to have vanished.
A huge number turned into .inf
A number too large for floating point, like 1e400, becomes Infinity when parsed and is written as YAML's .inf. Store it as a string if you need it preserved.
The output starts with a plain word instead of key: value
The top level of your JSON was a string, number, or array rather than an object. "just a string" converts to the bare scalar just a string, and an array converts to a list of - items. Many config files require a mapping at the top, so wrap the value in an object if your tool complains.
You wanted comments in the YAML
The converter cannot add them because JSON has none to carry over. Add # comments by hand after pasting; they will not affect how the file loads.
Related tasks
To reverse the conversion or check that the YAML loads the way you expect, run it back through the YAML to JSON converter. If your JSON will not parse, the JSON formatter is a quicker place to find the broken spot.
Questions this tool gets asked
Does the output work for Kubernetes manifests?
Yes. The output is plain YAML with two-space indentation and no anchors, which is exactly the style kubectl and Helm expect.
Is the conversion lossless?
For data it is: every JSON value maps to a YAML value. JSON has no comments, so there are no comments to lose in either direction.
Why does my JSON fail to convert?
The input must be strict JSON: double-quoted keys and strings, no trailing commas, no comments. The error message from the JSON parser points at the first invalid character.