Data guide
How to convert YAML to JSON (and JSON to YAML) without errors
YAML and JSON are two ways of writing the same data. JSON rules APIs and code; YAML rules configuration (Docker Compose, Kubernetes, GitHub Actions, Ansible). Sooner or later you need to go from one to the other —and that is where the indentation and quoting errors that eat your afternoon show up.
This guide explains how to convert between YAML and JSON in the browser, the most common failures and how to avoid them, and when each format fits best.
YAML and JSON: same data, different shape
Both represent data structures: objects (key-value pairs), lists and simple values (text, numbers, booleans). The difference is style:
- JSON uses braces, brackets and quotes. It is strict and compact, ideal for machines to read and for travelling over the network.
- YAML uses indentation and dashes instead of braces. It is easier for people to read and edit, which is why it dominates configuration files.
Because they describe the same thing, conversion is direct: a YAML object becomes a JSON object and vice versa, with no loss of information.
How to convert YAML to JSON in the browser, step by step
- Open the JSON ⇄ YAML converter. It runs entirely in your browser; your configuration is not uploaded to any server.
- Paste your YAML into the input box.
- Choose the YAML → JSON direction.
- Copy the resulting JSON. If you want it nicely formatted or validated, run it through the JSON formatter.
For the other direction (JSON → YAML), paste the JSON and switch the direction. Same flow.
Common conversion errors (and how to avoid them)
Almost all failures come from the YAML side, because it is sensitive to invisible details:
- Tabs in indentation: YAML does not allow tabs for indentation, only spaces. A hidden tab is the number-one cause of "my YAML won't convert". Set your editor to insert spaces.
- Inconsistent indentation: every item at the same level must line up with the same number of spaces. Two here and four there breaks the structure.
- A colon inside a value: a string like
time: 12:30confuses the parser. Wrap it in quotes:time: "12:30". - Values that look like something else:
no,yes,on,offare read as booleans; a postal code or a number with leading zeros can lose the zeros. If you want it treated as text, quote it. - JSON with a trailing comma: in the other direction, a trailing comma after the last item (
[1, 2, 3,]) is valid in some dialects but not in standard JSON, and it will break the conversion.
A good tool tells you where the error is instead of failing silently, so you can fix it without guessing.
When to use YAML and when to use JSON
- Use JSON for API responses, for exchanging data between programs, and when compactness matters.
- Use YAML for configuration that people edit: CI pipelines, manifests, application settings. It allows comments (JSON does not), which helps document things.
Converting between the two lets you work in the comfortable format and ship in the one the system expects.
Privacy: your configuration is not uploaded
Configuration files often contain server names, internal paths and, sometimes, secrets. Converting them on a website that uploads them to a server is an unnecessary risk. When you convert in the browser, your data never leaves your device: it is faster and there is no copy in anyone's hands.
Frequently asked questions
Is my YAML or JSON uploaded to a server?
No. The conversion happens entirely in your browser with JavaScript. Your configuration is never sent to the internet.
Why won’t my YAML convert?
The most common cause is tabs: YAML only allows spaces for indentation. Other frequent causes are inconsistent indentation and a colon inside an unquoted value. A tool that points out the error line helps you find it.
Is any information lost in the conversion?
No, because YAML and JSON represent the same data structures. The only thing that does not carry over is YAML comments: JSON has no comments, so they are dropped when converting to JSON.
Can I convert in both directions?
Yes. The converter is bidirectional: go from YAML to JSON and from JSON to YAML by switching the direction.
Does it keep the key order?
Yes, the order in which keys appear in the input is preserved.
Tools used in this guide
Everything in this guide happens inside your browser: your files are never uploaded to any server. That is the Colibrí promise.
More guides
- A free alternative for resizing an image without uploading it
- A free alternative for adding a watermark to your photos
- Free OCR: extract text from images and scanned PDFs without uploading them
- A free alternative to TinyPNG for compressing images
- A free alternative to password-protect a PDF without uploading it
- A free alternative to iLovePDF and SmallPDF for compressing PDFs
- How to edit a PDF for free (without uploading it anywhere)
- How to sign a PDF online without uploading it to the internet