What it does
YAML is the standard format for configuration in Kubernetes, Docker Compose, GitHub Actions and many other tools, while JSON is what APIs and programs usually exchange. This converter reads YAML with its own parser and writes JSON, or turns JSON back into readable YAML. It also covers what the former JSON to YAML Converter did: choose the mode “JSON to YAML”, and strings that a YAML parser could misread as numbers, booleans or nulls are quoted for you. If the input has an error you get the line and column.
What is supported
- Block and flow (
[a, b],{k: v}) collections, plain, single- and double-quoted strings with escapes, and block scalars (|and>with chomping indicators). - Anchors (
&name), aliases (*name) and merge keys (<<: *base); they are expanded in the output. - Multiple documents separated by
---become a JSON array. Duplicate keys and tab indentation are reported as errors.
Good to know
- Values follow the YAML 1.2 rules:
yes,noandonare text, not booleans, and0o17is an octal number. Some older tools (YAML 1.1) read them differently. - Normalize YAML rewrites the document in a consistent style. It cannot keep comments, and it expands anchors, so review the result before replacing a file.
- Custom tags such as
!Refare ignored, and explicit types like!!binaryare not decoded. JSON cannot hold.infor.nan, so those are reported.
Example: anchors, merge keys and several documents
This YAML uses an anchor (&base), a merge key (<<: *base) and a second document after the --- line:
base: &base
retries: 3
timeout: 30
prod:
<<: *base
timeout: 60
flags:
debug: yes
region: "eu-west-1"
---
second: docConverted to JSON, the anchor is expanded, the merged value is overridden by the key written in prod, and the two documents become an array:
[
{
"base": {
"retries": 3,
"timeout": 30
},
"prod": {
"retries": 3,
"timeout": 60
},
"flags": {
"debug": "yes",
"region": "eu-west-1"
}
},
{
"second": "doc"
}
]Notice that debug: yes becomes the string "yes". That is the YAML 1.2 rule; a YAML 1.1 tool would produce true.
JSON to YAML: why some strings are quoted
When you convert in the other direction, strings that a YAML parser could read as something else are quoted, so the data survives a round trip. This JSON:
{"enabled":"yes","version":"1.10","port":"8080","empty":"","note":"a: b"}becomes:
enabled: "yes"
version: "1.10"
port: "8080"
empty: ""
note: "a: b"Without the quotes, yes would be read as a boolean, 1.10 as the number 1.1 and 8080 as an integer.
Frequently asked questions
Are comments kept when I convert?
No. JSON cannot hold comments, and Normalize YAML cannot keep them either, so review the result before you replace a file.
How are multiple YAML documents converted?
Documents separated by --- become a JSON array, as in the example above.
Are anchors and aliases supported?
Yes. Anchors, aliases and merge keys are expanded in the output.
Is my data uploaded?
No. Both directions run in your browser.
Privacy
This tool runs entirely in your browser. What you enter is processed on your device and is not sent to a server.