Convert JSON to YAML
Paste your JSON, or drop a .json file, and the YAML appears as you type. Nothing is uploaded, so an API response or a config stays on your machine.
How to use it#
- Drop a .json file on the box at the top, or paste your JSON into the text box under it. A dropped file opens in the text box, where you can edit it.
- Pick 2 or 4 spaces of indentation.
- Tick sort keys if you want them alphabetical rather than in the order they arrived.
- Copy the result, or download it as a .yaml file named after the one you dropped.
Why anyone converts this way#
JSON is what a machine sends and YAML is what a person edits. The moment a payload becomes something a human has to maintain, a Kubernetes manifest, a CI pipeline, a docker compose file, the brackets and quotes start getting in the way and the indentation starts helping.
YAML also lets you add comments, which is usually the reason for the conversion. A config nobody can annotate is a config nobody can hand over.
What you get back#
Keys keep the order they arrived in by default, because in a hand-written config that order usually carries meaning: the important settings sit at the top. Sort keys puts them in alphabetical order instead, which is the better choice when two files are about to be compared, since a diff of two sorted files shows only what actually differs.
Long strings are written on one line rather than folded. YAML is allowed to wrap a long value across several lines, and it means the same thing, but a URL broken over three lines is alarming to read and easy to break by editing carelessly.
A string that would otherwise be read as something else comes back quoted. The value "3" is written as '3' so it stays a string, which is the difference between a version number and a number.
YAML is stricter than it looks#
The indentation is the structure, so it has to be spaces. Tabs are not permitted for indentation anywhere in YAML, and an editor set to insert tabs will produce a file no parser accepts. Most editors can be told to use spaces for .yaml and .yml files specifically.
The other thing to watch is that YAML is a superset of JSON, which means your original JSON was already valid YAML. Converting it is about readability, not about compatibility, and anything that accepts YAML would have taken the JSON as it was.
Numbers, repeated keys, and dates#
Numbers are copied as written. A 20 digit ID, too long for a JavaScript number, keeps every digit, and 1.50 stays 1.50 rather than becoming 1.5. A key that appears twice in one object is written once, with its last value, because YAML does not allow a repeated key and the last value is what JSON readers keep.
Anything not expressible in JSON to begin with, such as a date object or a function, is not in your input either: by the time it is JSON it is a string, a number, or nothing. The conversion cannot recover a type that was already flattened.
Frequently asked questions#
Is my JSON uploaded anywhere?
#
No. A dropped file is read and converted in this tab, and so is pasted text. Nothing is sent to a server, so an API response with customer data in it stays on your machine.
Should I sort the keys?
#
Sort them when the file is about to be compared against another, because a diff of two sorted files shows only the real differences. Leave them alone for a config a person will read, where the order the keys arrived in usually puts the important ones first.
Why are some of my strings quoted and others not?
#
Quotes appear only where they are needed to preserve the type. A value like "3" or "true" would be read back as a number or a boolean without them, so those get quotes and ordinary words do not.
Can I use tabs to indent the result?
#
No, and neither can anything else. YAML forbids tabs for indentation, so a file indented with them is rejected by every parser. The choice here is between two and four spaces.
Is my JSON already valid YAML?
#
Yes. YAML is a superset of JSON, so anything that reads YAML already accepts your JSON as it stands. Converting is about making the file readable and commentable, not about compatibility.
Is YML different from YAML?
#
No. .yml is the shorter extension for the same format, and every YAML parser reads both. The download is saved as .yaml, so rename it to .yml if your project uses that name, as many Docker Compose files and GitHub Actions workflows do.
Where did my long URL go?
#
Nowhere. Long values are written on a single line rather than folded across several, which some converters do. Folding is valid YAML and means the same thing, but it makes a URL look broken and is easy to damage when editing.