About this tool
Write JSON as YAML for a config file
This tool converts JSON to YAML in your browser as you type. Objects become indented blocks, lists become dashed items and strings are quoted only where YAML would misread them, such as true, null or a number in quotes. Copy the result or save a .yaml file. Nothing leaves your device.
Readable YAML, two spaces a level
Objects are written as blocks with two spaces for each level, lists as lines that start with a dash, and a list of objects with the first key beside its dash. An empty list is written [] and an empty object {}, since YAML has no blank way to say them.
The result is block style, the way people write configuration by hand, not the one-line form that looks like JSON.
Quotes only where YAML needs them
YAML guesses types from plain text, so the string "true" written plain would come back as a boolean, and "123" as a number. This tool puts those in double quotes. It does the same for null, yes and no, text with a colon or a hash, text with a line break, text that starts with a symbol and text with a space at either end.
Everything else stays plain, so ordinary words and file paths read the way you would write them. Keys follow the same rule.
The data stays the same
Numbers keep every digit they had, and true, false and null stay what they were. Key order is kept unless you turn on Sort keys, which puts the keys of every object in alphabetical order, which suits comparing two files.
YAML does not allow a key twice in one object. If your JSON has one, the last value wins, as it does when a program reads the JSON, and it is written once.
Fix the JSON first
If the text is not valid JSON, the page shows the line and column of the first problem instead of YAML. The JSON formatter on this site formats and checks the same text, and its CSV mode writes a list of records as a table.
How it works
-
Step 1:Paste your JSON
Paste it, open a .json file or drop one on the page.
-
Step 2:Read the YAML
It appears as you type. Turn on Sort keys if you want the keys in alphabetical order.
-
Step 3:Copy or save it
Copy puts it on the clipboard. Download saves a .yaml file named after your JSON file, or data.yaml.
Questions, answered
How do I convert JSON to YAML?
Paste the JSON into the Input box and the YAML appears in the Output box as you type. Copy it, or press Download to save a .yaml file.
Why are some of my strings in quotes?
YAML would read them as something else without quotes: true, null, yes, no or digits as a boolean, empty value or number, and text with a colon, a hash or a line break as syntax. Quotes keep them strings.
Does it keep the order of my keys?
Yes, unless you turn on Sort keys. Then the keys of every object are put in alphabetical order, by character code.
What happens to a key that appears twice?
YAML does not allow it, so it is written once with the last value, the one a program would use when it reads your JSON.
Can I turn YAML back into JSON here?
Not yet. This page goes one way, from JSON to YAML. Reading YAML is a bigger job, and nothing here guesses at it.
Is my config sent anywhere?
No. The conversion runs in this page, on your device. Nothing is saved or put in the address of the page, so a link to it shares nothing you typed.