JSON to YAML Converter
Turns JSON into clean, readable YAML. Strings that YAML would misread, such as NO, on, 1.10 or 0755, are put in quotes, and numbers are copied exactly as written.
- Runs in your browser
- Nothing uploaded
- Free, no sign-up
How to Use JSON to YAML Converter
- Paste your JSON, open a .json file, or click Sample.
- Pick the indent (2 or 4 spaces) and the other options: quote all strings, | blocks for multi-line text, sorted keys, or one YAML document per array item.
- Read the YAML on the right. The notes under it list every string that was quoted and why.
- If the JSON has errors, the exact line and column are shown. Click Fix common mistakes to repair comments, single quotes and trailing commas.
- Copy the YAML or download it as a .yaml file.
Example: a service config with values YAML would misread
This is the Sample button. It looks like a normal settings file, but five of its strings would change meaning if they were written into YAML without quotes:
{
"service": "billing-api",
"version": "1.10",
"replicas": 3,
"debug": false,
"country": "NO",
"zip": "02134",
"schedule": "12:30",
"tags": ["payments", "eu-west", "on"],
"owner": null,
"env": {"LOG_LEVEL": "info", "TIMEOUT_MS": 2500},
"notes": "Restart after deploys.\nCheck the queue first.\n",
"endpoints": [
{"path": "/invoices", "methods": ["GET", "POST"]},
{"path": "/health", "methods": ["GET"]}
]
}
The converter returns:
service: billing-api
version: '1.10'
replicas: 3
debug: false
country: 'NO'
zip: '02134'
schedule: '12:30'
tags:
- payments
- eu-west
- 'on'
owner: null
env:
LOG_LEVEL: info
TIMEOUT_MS: 2500
notes: |
Restart after deploys.
Check the queue first.
endpoints:
- path: /invoices
methods:
- GET
- POST
- path: /health
methods:
- GET
Look at the quoted values. '1.10' stays a version string instead of becoming the number 1.1. 'NO' and 'on' stay text for tools that follow the older YAML 1.1 rules, where they mean false and true. '02134' keeps its leading zero, and '12:30' is not turned into the number 750. The notes under the result say the same thing in words, so you can see why each quote is there.
The two-line notes string became a | block, which keeps the line breaks readable. Numbers, true, false and null are copied as they were.
How JSON strings come out in YAML
Each row is one JSON string run through the tool with default options. We read every result back with two YAML readers, js-yaml and PyYAML, and both returned the original string.
| JSON string | YAML written | Why |
|---|---|---|
"NO" |
'NO' |
YAML 1.1 readers such as PyYAML read a bare NO as false (the “Norway problem”) |
"on" |
'on' |
A bare on is true in YAML 1.1 |
"yes" |
'yes' |
A bare yes is true in YAML 1.1 |
"true" |
'true' |
A bare true is a boolean in every YAML version |
"null" |
'null' |
A bare null is the null value |
"" |
'' |
An empty value after the colon would be read as null |
"1.10" |
'1.10' |
Bare 1.10 is the number 1.1, so the trailing zero would be lost |
"0755" |
'0755' |
Bare 0755 is the number 755 in YAML 1.2 and octal 493 in YAML 1.1 |
"1e3" |
'1e3' |
Bare 1e3 is the number 1000 in YAML 1.2 |
"12:30" |
'12:30' |
Bare 12:30 is the base-60 number 750 in YAML 1.1 |
"2024-01-15" |
'2024-01-15' |
Many readers turn a bare date into a date object |
"key: value" |
'key: value' |
A colon followed by a space starts a new key |
"#general" |
'#general' |
A # at the start begins a comment |
"- item" |
'- item' |
A dash and a space start a list item |
"*important*" |
'*important*' |
A * at the start refers to an anchor (an alias) |
" padded " |
' padded ' |
Spaces at the start and end would be dropped |
"It's fine" |
It's fine |
Nothing here is special, so no quotes are needed |
"café" |
café |
Accented letters and emoji stay as they are |
"line one\nline two" |
|- |
Line breaks become a | block; the – drops the final newline |
How it works
- The JSON is read with a strict parser. An error reports the line and column, and the optional fixer repairs comments, single quotes, unquoted keys, trailing commas and Python values such as True and None, then lists each change.
- Numbers are copied character for character.
12345678901234567890and1.50are not rounded or reformatted, which a converter built onJSON.parsecannot promise. - A string is left bare only when every YAML reader will read it back as the same text. Anything that looks like a number, a boolean, null or a date in YAML 1.2 or YAML 1.1, starts with a YAML symbol, contains
:or#, or has spaces at either end is quoted. - Single quotes are used where possible. Control characters such as tabs inside a value, or a lone carriage return, switch to double quotes with escapes like
\tand\u0001. - Multi-line strings become literal blocks. The block header shows how the final line breaks are kept:
|-for none,|for one,|+for more. Text that starts with spaces also gets an indent number, as in|2-. - Keys follow the same quoting rules, so a key such as
onor12comes out as'on'or'12'.
Limits
- JSON has no comments, so the YAML has none either. Add them by hand after converting.
- Repeated blocks are written out in full. The tool does not create anchors (
&name) and aliases (*name) for you. - If a key appears twice in the JSON, YAML cannot hold both, so the last value is kept and a warning names the key.
- Numbers in exponent form such as
1e5stay as written. YAML 1.2 reads them as numbers, but PyYAML reads them as text, so the tool warns you when it sees one. - Very large files work, but the result box gets slow to scroll past a few megabytes. Downloading the .yaml file is easier then.
Frequently asked questions
Why is NO in quotes in my YAML?
In YAML 1.1, a bare NO, no, off or n is read as false. That spec is old, but PyYAML and several other common libraries still follow it, so country codes such as Norway’s NO turned into false in real projects. Quoting the value keeps it text for every reader.
Is JSON already valid YAML?
Almost always. YAML 1.2 was designed so that JSON documents are valid YAML, and the YAML to JSON converter reads JSON input without complaint. Converting still helps, because YAML without braces and quotes is easier to read and edit by hand.
How do I turn a JSON array into several Kubernetes manifests?
Turn on “Top-level array as separate documents”. Each item of the array becomes its own YAML document starting with —, which is the format kubectl apply -f expects for a multi-object file.
Can I check the YAML before I use it?
Paste it into the YAML validator. It reports syntax errors by line and warns about values that YAML 1.1 and YAML 1.2 read differently.
Related Tools
YAML to JSON Converter →
Converts YAML to JSON with anchors, aliases and
Convert CSV to JSON →
Converts CSV or TSV to JSON in your browser. It detects the separator, handles…
Convert CSV to YAML →
Convert CSV to YAML with smart type detection, multi-line block scalars, reserved-word quoting (no…
JSON to CSV Converter →
Turns a JSON array into CSV or TSV. Nested fields become their own columns,…
Convert JSON to PDF Report →
Convert JSON data to formatted PDF reports instantly. Free JSON to PDF converter with…
JSON to XML Converter →
Converts JSON to well-formed XML. Keys starting with @ become attributes, arrays become repeated…
XML to JSON Converter →
Converts XML to JSON with attributes, repeated elements, CDATA and namespaces handled. You choose…
XML to YAML Converter →
Convert XML into readable YAML that mirrors the document tree, with indentation for nesting.
YAML to CSV Converter →
Convert a YAML list of items into CSV, with keys as columns and values…
YAML to TOML Converter →
Convert a YAML mapping into TOML, with nested mappings as tables and lists as…
YAML Validator →
Checks YAML as you type. Syntax errors point to the exact line and column…
Analyze JSON Online and Validate JSON Structure →
Analyze JSON Online Validate & Analyze JSON Structure with detailed statistics including depth, key…