How to convert JSON to YAML, free and without uploading
To convert JSON to YAML, paste your JSON into the JSON Input box, click Open File, or click Load Sample to try it. The YAML Output box appears about 0.25 seconds after you stop typing. Choose Indent (2 spaces or 4 spaces), Style (Block Style or Flow Style) and Sort Keys above the boxes, then click Copy, or Download to save converted.yaml. The built-in sample, 304 bytes of JSON, becomes 233 bytes of YAML on 17 lines. Strings that a YAML parser could mistake for another type, such as 62701, yes or 2024-01-01, are quoted so they stay text.
It runs in your browser; nothing is uploaded (you can check the Network tab in DevTools). Files chosen with Open File are read on your device. There is no account and nothing to install.
YAML describes the same data as JSON, objects, arrays and values, but replaces braces and most quotes with indentation, which makes configuration files easier to read and review. A converter has one real job beyond layout: deciding when a string must be quoted. A bare no or 0755 can silently become a boolean or a number in a YAML parser, so the writer here quotes every string that could.
To go the other way, use the YAML to JSON converter. Check the input first with the JSON validator or tidy it in the JSON formatter, and see the same data as markup or a table with the JSON to XML converter and the JSON to CSV converter.
Table of Use: how JSON becomes YAML
| In your JSON | YAML output | Note |
|---|---|---|
{"name":"John Doe","age":30} | name: John Doe
age: 30 | Strings that cannot be misread are written without quotes |
"zip": "62701" | zip: '62701' | A string that looks like a number is quoted so it stays text |
"a": "yes", "b": "off", "c": "y" | a: 'yes'
b: 'off'
c: 'y' | Words that YAML 1.1 parsers read as booleans are quoted |
"d": "2024-01-01" | d: '2024-01-01' | Date-like strings are quoted so they are not turned into dates |
"hobbies": ["reading","hiking"] | hobbies:
- reading
- hiking | Block Style; Flow Style gives hobbies: [reading, hiking] |
"note": "Line one\nLine two" | note: |-
Line one
Line two | Block Style writes a literal block; Flow Style gives "Line one\nLine two" |
{"a":null,"b":true,"c":{},"d":[]} | a: null
b: true
c: {}
d: [] | Empty objects and arrays stay on the key's line |
{"big":12345678901234567890,"d":1.50,"e":1e5} | big: 12345678901234567890
d: 1.50
e: 1.0e+5 | Digits are kept; an exponent gets a decimal point and a sign |
{"my key":1,"yes":2} | my key: 1
'yes': 2 | Keys are quoted by the same rules as values |
{"a":1,"a":2} | a: 2 | YAML forbids duplicate keys, so the last value wins |
Features
- Block or flow output. Block Style is one key per line with dashes for lists. Flow Style is a single compact line, and the sample comes out at 227 bytes in flow style against 233 in block style.
- Indent of 2 or 4 spaces. Tabs are not offered, because YAML does not allow them for indentation.
- Sort Keys. Tick it to sort keys at every level by character code, so capital letters come before lowercase ones (B before a). Two files with sorted keys are easier to compare in the text diff tool.
- Quoting that survives a round trip. Plain text is left bare. Booleans, nulls, numbers, dates, times and text with
:or a leading symbol are quoted, and control characters become double-quoted escapes. - Literal blocks for long text. Block style writes a string with line breaks as a
|block and records the trailing line breaks with-or+. A string that holds a carriage return or another control or non-printable character, or whose first non-empty line starts with a space or tab, is double-quoted instead. - Exact numbers, ordered keys. A strict JSON reader replaces JSON.parse, so long integers and 1.50 keep their digits and numeric-looking keys keep their order.
- Statistics and errors. JSON Size, YAML Size and YAML Lines are shown once there is output, and invalid JSON is reported with its line and column.
- Open File, Copy, Download. Download names the file after the one you opened, with a .yaml extension.
How to use the JSON to YAML converter
- Paste your JSON into the JSON Input box, click Open File, or click Load Sample. Click Clear All to start again.
- Set Indent to 2 spaces or 4 spaces.
- Set Style to Block Style for readable config files, or Flow Style for one compact line.
- Tick Sort Keys if you want keys sorted at every level.
- Read the YAML Output and the JSON Size, YAML Size and YAML Lines figures. Click Convert to YAML to run it again.
- Click Copy, or Download to save the .yaml file.
Who can use it
- DevOps and platform engineers turning a JSON config or API response into YAML for a tool that reads YAML, and writing job schedules with the cron expression generator.
- Developers starting from a spreadsheet, who can convert it to JSON with the CSV to JSON converter and then to YAML here.
- Teams with XML data that go through the XML to JSON converter before they become YAML.
- Technical writers who want readable YAML examples for documentation.
- Students comparing how the same data looks in both formats.
FAQs
How do I convert JSON to YAML?
Paste your JSON into the JSON Input box, click Open File, or click Load Sample to try it. The YAML Output box appears about 0.25 seconds after you stop typing. Choose Indent, Style and Sort Keys above the boxes if you want something other than the defaults, then click Copy, or Download to save converted.yaml.
What is the difference between Block Style and Flow Style?
Block Style, the default, puts each key on its own line and uses indentation and dashes for nesting, which is the layout most config files use. Flow Style writes the whole document on one line with braces and brackets, such as {name: John Doe, hobbies: [reading, hiking]}. Both describe the same data. Multi-line strings are written as quoted text in flow style.
Why are some values wrapped in quotes?
A plain YAML value can be read as something other than text. Older YAML 1.1 parsers treat yes, no, on, off and y as booleans, and any parser may read 0755, 1e5, 12:30 or 2024-01-01 as a number or date. The converter quotes such strings, so "62701" is written as '62701' and stays a string. Other strings are left plain.
How are multi-line strings written?
In block style, a string with line breaks becomes a literal block that starts with | and keeps each line on its own line, indented under the key. A -, nothing or + after the bar records whether the text ends without a line break, with one, or with several. A string that holds a carriage return or another control or non-printable character, or whose first non-empty line starts with a space or tab, is written as one double-quoted line with \n escapes, as in flow style.
Does it keep long numbers and key order?
Yes. Numbers are copied exactly as written, so 12345678901234567890 and 1.50 keep every digit. Keys stay in the order of your JSON, even keys such as 2 and 1, unless you tick Sort Keys. One change is deliberate: an exponent such as 1e5 is written as 1.0e+5, the same value in a form that YAML 1.1 parsers also read as a number.
Can I use tabs for indentation?
No. YAML does not allow tab characters for indentation, so Indent offers only 2 spaces and 4 spaces. The choice changes how far each nested level moves in, and the sample JSON gives 233 bytes of YAML with 2 spaces and 251 bytes with 4 spaces. The data is the same either way, so pick the width your project already uses.
Why does it say my JSON is invalid?
The converter reads strict JSON. Comments, single-quoted strings, trailing commas and unquoted keys are errors, and the message gives the line and column to fix. Empty input just clears the output. If the data is a YAML file rather than JSON, use the YAML to JSON converter in the other direction. If you are unsure, run it through a JSON validator first.
Is my JSON uploaded to a server?
It runs in your browser; nothing is uploaded (you can check the Network tab in DevTools). The JSON is parsed and written as YAML by a script that ships with the page, and files chosen with Open File are read on your device. Nothing is sent to ZipConvert or anyone else, so config files with private values stay on your machine.