Free YAML to JSON converter
YAML to JSON converter converted right in your browser
Paste a config and read valid JSON next to it, with 2, 4 or tab indentation. Sort keys, minify, then copy, download a .json file or send a link that carries your data.
- Free, no sign-up
- Your YAML never leaves this browser
- JSON appears as you type
From a YAML file to JSON you can paste anywhere
Every option reconverts the same YAML at once, so you can compare layouts before you copy.
- Step 01
Paste your YAML
Drop in a docker-compose file, a Kubernetes manifest or a CI config. The box starts empty, and Paste example loads a short sample.
- Step 02
Set the output style
Choose 2 spaces, 4 spaces or a tab. Switch on Sort keys to order every object alphabetically, or Minify to get one compact line.
- Step 03
Fix errors by line
If the YAML is broken, the message names the line and column and shows that line, so you can correct it without guessing.
- Step 04
Copy, save or share
Copy keeps the indentation, Download .json saves converted.json, and Share link packs your input and options into the address.
What you get from every YAML paste
- Valid JSON that appears about a third of a second after you stop typing
- Indent of 2 spaces, 4 spaces or a tab, with Minify for one line
- Recursive key sorting for stable diffs
- Several documents separated by --- become a JSON array
- Errors with line and column and the offending line
- Copy that keeps every space and line break
- A light or dark panel for the JSON, chosen by you
- Your draft restored after a reload, plus shareable links
How the conversion works and what is kept
YAML and JSON describe the same kinds of data: objects with named keys, lists, strings, numbers, true or false, and null. The converter reads your YAML with the YAML 1.2 rules and writes the equivalent JSON. Mappings become objects, sequences become arrays, and plain values keep their type, so port: 8080 turns into the number 8080 while port: "8080" stays a string.
Comments and anchors need a word. JSON has no comments, so lines starting with a hash sign are dropped. Anchors and aliases, written with an ampersand and an asterisk, are expanded: every place that uses an alias receives a full copy of the anchored data. The merge key, written as two angle brackets and a colon, is applied before the JSON is written.
A file can hold more than one document. When your YAML contains lines made of three dashes, each part is read as its own document. One document gives you that object or value directly. Two or more give you a JSON array with one entry per document, in the same order, which is handy for multi-resource Kubernetes files.
The output style is yours to choose. Two spaces is the common default, four spaces suits many style guides, and a tab character keeps files small when your editor shows tabs at any width. Minify removes every optional space and line break and disables the indent choice, because a single line has no indentation. Sort keys orders the keys of every object alphabetically, including objects nested inside lists, while list items stay in their original order.
When the YAML cannot be read, the page shows the line and column of the first problem, the parser message and the source line itself. The previous JSON is hidden until the input is valid again, so you never copy stale output.
Share link builds an address that ends with a hash part. Your YAML and options are packed into it in your browser, compressed when the browser supports it, and encoded as text. Browsers never send the part after the hash to a server, so the data stays with you and the person who opens the link. Links are limited to about eight thousand characters; a larger file is better downloaded as .json.
What is saved. The YAML, the indent, the two switches and the panel theme are stored in this browser after each change, so a reload brings your work back. Clear removes the text from the draft as well.
Worked example: a tiny service file
These results come from the same converter code as the tool, applied to a short YAML with a list of ports.
| Input lines | 5 |
|---|---|
| JSON lines with 2-space indent | 8 |
| Characters when minified | 46 |
| Key order after Sort keys | enabled, name, ports |
| Two documents split by dashes | [{"a":1},{"b":2}] |
Numbers such as 80 and 443 stay numbers and true stays a boolean, because YAML 1.2 types are carried over.
What the converter is built for
- It converts YAML to JSON only. Going the other way, or reading XML and CSV, takes a different tool.
- Comments are not kept, since JSON has no place for them.
- Share links hold about eight thousand characters. Bigger inputs are best saved with Download .json.
- Dates and other special values are written as plain text or numbers, as JSON has no such types.
YAML to JSON questions
Is my YAML uploaded anywhere?
No. Parsing happens in your browser, and the text is kept only in this browser's local storage. Share links carry data in the part after the hash, which is never sent to a server.
What happens to comments?
They are dropped, because JSON cannot store comments.
How are several documents handled?
Documents separated by --- become a JSON array in the same order. A single document is written as itself.
Does Copy keep the indentation?
Yes. The text on the clipboard is exactly what the panel shows, with every space, tab and line break.
Why can I not pick an indent when Minify is on?
Minified JSON is a single line, so there is nothing to indent. Switch Minify off to choose 2, 4 or tab again.
What does Sort keys do?
It orders the keys of every object alphabetically, including nested ones. Items in a list keep their order.
How big can a share link be?
About eight thousand characters after compression. If your data is larger, the page says so and you can download the .json file instead.
Related tools
- Regex GeneratorReady JavaScript regex for email, phone, postal code, DNI, URL and more, tested live on your text.
- Character Frequency CounterPaste text, get a table of how often each character appears, with counts and percentages.
- Base64 to PDF DecoderPaste Base64 or a data URI, check it is a real PDF and download it.
Got a config waiting to be converted?
Paste it and read the JSON in a moment, free and without an account.
About ToolperLast updated: Privacy