JSON to YAML Converter
Convert JSON to YAML or YAML to JSON as you type. Key order and numbers are kept exactly, and strings that YAML would misread are quoted. It runs in your browser and nothing is sent anywhere.
YAML output
Converting…
How to convert JSON to YAML
- Pick a direction: JSON → YAML or YAML → JSON.
- Paste your input. It converts as you type, and an error names the line and column where parsing stopped.
- Set the indent, quoting style or YAML version if you need to, then copy or download the result.
Example: JSON to YAML
This JSON:
{
"service": "checkout",
"country": "NO",
"feature": "on",
"fileMode": "0755",
"port": 8080,
"orderId": 12345678901234567890,
"hosts": ["eu-1.example.com", "eu-2.example.com"],
"retry": { "attempts": 3, "backoff": 1.50 }
}converts to this YAML:
service: checkout country: "NO" feature: "on" fileMode: "0755" port: 8080 orderId: 12345678901234567890 hosts: - eu-1.example.com - eu-2.example.com retry: attempts: 3 backoff: 1.50
"NO", "on" and "0755" stay quoted so no YAML parser reads them as false, true or a number. The 20-digit orderId and 1.50 are copied as written instead of being rounded.
Example: YAML to JSON with anchors and two documents
defaults: &defaults timeout: 30 retries: 2 production: <<: *defaults retries: 5 enabled: no --- name: second document
converts with YAML 1.2 rules to:
[
{
"defaults": {
"timeout": 30,
"retries": 2
},
"production": {
"timeout": 30,
"retries": 5
},
"enabled": "no"
},
{
"name": "second document"
}
]The <<: *defaults merge copies timeout and retries, and the local retries: 5 wins. enabled: no is the string no under YAML 1.2; under YAML 1.1 it is false. The two documents become a two-item array.
YAML gotchas to know before you convert
- The Norway problem. In YAML 1.1, unquoted
no,yes,on,off,yandnare booleans, socountry: NOmeansfalse. YAML 1.2 fixed this, but PyYAML and many CI tools still follow 1.1. Quote these strings. - Octal-looking strings.
mode: 0755is the number 493 in YAML 1.1 and 755 in YAML 1.2. Neither is the string you meant. File modes, ZIP codes and version numbers like1.10need quotes. - Tabs. YAML forbids tabs for indentation. A file indented with tabs fails with a “Tabs are not allowed” error at the first tab; re-indent with spaces.
- Comments and anchors do not survive. JSON has no comments or references, so converting YAML to JSON drops comments and expands every alias into a copy.
When to use JSON and when to use YAML
Use JSON for data that programs exchange: API payloads, lock files and anything generated by code. It has one way to write each value, so it is fast to parse and hard to misread. Use YAML for files people edit by hand, such as Kubernetes manifests, GitHub Actions workflows and Docker Compose files, where comments and less punctuation help. Every JSON document is also valid YAML 1.2, so a YAML tool will accept JSON input.
Need types for the JSON once it is converted? The JSON to TypeScript converter generates interfaces from a sample.
Frequently asked questions
Why is "NO" quoted in the YAML output?
YAML 1.1 parsers, including PyYAML and many older tools, read unquoted no, yes, on, off, y and n as booleans. This is the Norway problem: the country code NO becomes false. The converter quotes any string that a YAML 1.1 or 1.2 parser would read as something else, so the value stays a string everywhere.
Are YAML booleans read as YAML 1.1 or 1.2?
YAML 1.2 by default, where only true and false are booleans and no stays a string. Choose YAML 1.1 under YAML version to read yes, no, on and off as booleans and 0755 as the octal number 493, the way PyYAML does.
Does the converter keep big numbers and key order?
Yes. Numbers are copied as written, so 12345678901234567890 and 1.50 are not rounded to 12345678901234567000 and 1.5. Keys stay in input order, including number-like keys such as "10", which JSON.parse would move to the front.
What happens to anchors, aliases and multiple documents?
Aliases (*name) are replaced with a copy of their anchor and merge keys (<<) are applied, because JSON has no references. A stream with several --- documents becomes a JSON array with one item per document. Up to 100 alias expansions are allowed, which stops alias bombs.
Is my data sent anywhere?
No. Conversion runs in your browser. Your input is not uploaded, logged, saved or added to the URL.
How large can the input be?
Up to 1 MB (1,048,576 characters) and 200 levels of nesting. Conversion runs in a background thread, so the page stays responsive while a large file converts.