JSON to YAML Converter
Paste or upload your JSON and get clean, valid YAML in one click. Choose your indentation, sort keys and copy the result. Free, fast and private.
Everything runs in your browser. Strings that could be mistaken for numbers, booleans or null are quoted automatically, and text with line breaks is written as a block.
What Is a JSON to YAML Converter?
A JSON to YAML converter rewrites data from JSON (JavaScript Object Notation) into YAML (YAML Ain’t Markup Language). Both formats store the same kinds of data: objects, lists, text, numbers, true or false values and null. JSON uses braces, brackets and quotes. YAML uses indentation and dashes, so it is shorter and easier for people to read.
Our free tool converts as you type. Paste JSON or upload a .json file and valid YAML appears instantly. You can choose 2 or 4 space indentation, sort the keys, quote every string, or add the — document start marker.
How to Convert JSON to YAML
- Paste your JSON into the input box, or click Upload to load a .json file. Click Sample to see an example.
- Pick the indentation. Most projects use 2 spaces, and Kubernetes and Docker Compose files almost always do.
- Optionally sort the keys, quote all strings or add the start marker.
- The YAML output updates as you type. Use Copy or Download to save it as a .yaml file.
If the JSON is not valid, the tool shows the error message from the parser so you can find the problem.
How JSON Is Converted to YAML
The converter follows the standard YAML rules below.
| JSON | YAML result |
|---|---|
{ "name": "Ava" } | name: Ava |
[ "a", "b" ] | - a and - b on separate lines |
| Nested objects | Indented keys under the parent key |
Text that looks like a boolean, such as "true" | Stays in quotes so it is not read as a real boolean |
Text that looks like a number, such as "123" | Stays in quotes so it is not read as a number |
null | null |
| Empty array and empty object | [] and {} |
| Text with line breaks | Written as a block with the | marker |
JSON vs YAML: What Is the Difference?
| Feature | JSON | YAML |
|---|---|---|
| Structure | Braces, brackets and commas | Indentation and dashes |
| Comments | Not allowed | Allowed with # |
| Quotes | Required on keys and strings | Usually optional |
| Readability | Good for machines | Easier for people |
| Strictness | Very strict | Flexible, but sensitive to indentation |
| Typical use | APIs and data exchange | Configuration files and pipelines |
In YAML 1.2, most valid JSON is also valid YAML, but a proper conversion gives you the cleaner, more readable style that people expect in config files.
Why Convert JSON to YAML?
- Kubernetes: manifests for pods, services and deployments are written in YAML.
- Docker Compose: the docker-compose.yml file describes your containers in YAML.
- CI and CD pipelines: GitHub Actions, GitLab CI and many other tools read YAML workflows.
- OpenAPI and Swagger: API descriptions are often easier to edit in YAML than in JSON.
- Ansible and config files: YAML allows comments, so you can explain each setting.
YAML Syntax Tips
- Use spaces, never tabs. YAML does not allow tab characters for indentation.
- Keep indentation consistent. A child key must be indented more than its parent, and siblings must line up exactly.
- Quote tricky values. Words like yes, no, on and off, numbers stored as text, dates and text that contains a colon followed by a space should be in quotes.
- Add comments with #. Anything after a hash sign on a line is ignored.
- Use a block for long text. The
|marker keeps line breaks exactly as written.
Common JSON Errors and How to Fix Them
- Trailing commas: a comma after the last item in an object or array is not allowed.
- Single quotes: JSON strings and keys must use double quotes.
- Unquoted keys: every key must be a string in double quotes.
- Comments: JSON does not support // or /* */ comments, so remove them first.
- Special values: NaN, Infinity and undefined are not valid JSON.
- Missing brackets: every opening brace or bracket needs a matching closing one.
Who Uses a JSON to YAML Converter?
DevOps engineers use it to turn API output into Kubernetes or Compose configuration. Developers use it to move settings between tools. Technical writers use it to document APIs, and students use it to learn the difference between the two formats.
Need another format? Try our XML to JSON converter or the CSV to XML converter.
Is It Safe to Paste My JSON Here?
Yes. The conversion runs entirely in your browser with JavaScript. Your JSON is not uploaded, stored or sent to any server. As a general habit, still avoid pasting passwords, tokens or other secrets into any online tool.
Frequently Asked Questions
How do I convert JSON to YAML?
Paste your JSON into the input box or upload a .json file. The YAML appears instantly in the output box. Then copy it or download it as a .yaml file.
Is YAML a superset of JSON?
In YAML 1.2, most valid JSON is also valid YAML. Still, converting gives you the cleaner block style with indentation and dashes that people expect in configuration files.
Why are some strings wrapped in quotes in the output?
The converter adds quotes when plain text could be misread, for example the words true, false, yes, no or null, numbers stored as text, dates, empty strings, or text that contains a colon followed by a space.
How are arrays and nested objects shown in YAML?
Objects become keys with indented children. Arrays become lists where every item starts with a dash. Empty arrays and objects are written as [] and {}.
Does the converter keep the order of the keys?
Yes. Keys stay in the same order as your JSON. Tick Sort keys A to Z if you want them in alphabetical order.
Why do I see an Invalid JSON message?
The input is not valid JSON. Common causes are trailing commas, single quotes, unquoted keys, comments and missing brackets. The message from the parser points to the place of the error.
Can I convert YAML back to JSON?
No, this page only converts JSON to YAML. For other formats, try the XML to JSON converter or the CSV to XML converter on this site.
Is this JSON to YAML converter free and private?
Yes. It is free with no sign-up and no limit. All processing happens in your browser, so your data is never sent to a server.
Related Tools
Explore other structured-data conversion and validation tools.