What does this tool do?
This is a free online YAML to JSON converter. Paste a YAML document on the left and the equivalent JSON appears on the right as you type. Flip the direction toggle and it works the other way too — JSON to YAML. Because both YAML and JSON describe the same underlying data model (maps, lists, strings, numbers, booleans and null), converting between them is lossless for the data itself.
The conversion runs entirely in your browser. Nothing you paste is sent to a server, so it is safe to use with config files, secrets templates, or anything you would not want to upload. It also means it keeps working offline once the page has loaded.
How to convert YAML to JSON
- Paste or type your YAML into the left box. Conversion happens live.
- The JSON result shows on the right. Use the Indent dropdown to switch between 2 spaces, 4 spaces, or tabs.
- Click Copy to put the result on your clipboard, or Download to save a
.jsonfile. - If your YAML has a syntax error, a red message shows exactly what went wrong and where.
- Press Sample any time to load an example you can edit.
YAML to JSON conversion rules (and gotchas)
YAML and JSON map onto the same data model, so the conversion is faithful — but a few YAML features have no JSON equivalent. Knowing these keeps the output from surprising you:
- Comments are dropped. JSON has no comment syntax, so every
# commentline in your YAML disappears. The data itself is preserved exactly. - Numbers lose insignificant zeros. An unquoted
version: 1.0is read as the number1.0and serialized to JSON as1— the trailing zero is gone. Wrap it in quotes ("1.0") to keep it a string. The same applies to ZIP codes, phone numbers and IDs with leading zeros. - Only
true/falseare booleans. This converter follows the modern YAML 1.2 spec, soyes,no,onandoffstay strings — unlike older YAML 1.1 parsers that turned them into booleans. Writetrueorfalseif you need a boolean. - Anchors and aliases are expanded. If your YAML reuses a block with
&anchorand*alias, the JSON writes the value out in full at every place it is referenced — JSON has no references. - One document at a time. A YAML stream can hold several documents separated by
---. A single JSON value cannot, so convert each document on its own. - Indentation must be spaces, never tabs. A stray tab is the single most common cause of a parse error, followed by inconsistent indentation and a missing colon.
Real-world examples
The most common reason developers convert YAML to JSON is to feed a config file written for humans into a tool or API that expects JSON. For example, this Kubernetes manifest:
apiVersion: v1 kind: ConfigMap metadata: name: app-config data: LOG_LEVEL: info REPLICAS: "3"
becomes JSON you can post to the Kubernetes API or pipe into a script:
{
"apiVersion": "v1",
"kind": "ConfigMap",
"metadata": { "name": "app-config" },
"data": { "LOG_LEVEL": "info", "REPLICAS": "3" }
}
The same pattern covers a docker-compose service, a GitHub Actions workflow, or an Ansible playbook — all written in YAML for readability, then converted to JSON when a script, a CI step, or an API needs to read them programmatically.
Convert YAML to JSON in code (Python, JavaScript, CLI)
This page is the zero-install option, but if you need the conversion inside a script the libraries are one-liners:
- Python:
import yaml, json; print(json.dumps(yaml.safe_load(open("in.yaml"))))— PyYAML'ssafe_loadparses,json.dumpsserializes. - JavaScript / Node:
JSON.stringify(require("js-yaml").load(yamlString))— this page usesjs-yamlunder the hood. - Command line:
yq -o=json '.' in.yamlconverts a YAML file to JSON in one command.
For a quick one-off, pasting into the box above is faster than reaching for a library — and nothing leaves your machine.
JSON to YAML
Going the other way, this tool produces clean, block-style YAML: two-space indentation, no unnecessary quoting, and arrays as dash lists. That makes it handy for turning an API response or a package.json snippet into a Kubernetes manifest, a GitHub Actions workflow, or a docker-compose file — formats that are far more pleasant to read and edit as YAML.
YAML vs JSON — which should you use?
JSON is the lingua franca of web APIs: strict, unambiguous, and supported everywhere. It is great for machines but noisy for humans because of all the braces and quotes. YAML is a superset of JSON designed for humans — it drops the punctuation, allows comments, and reads top-to-bottom like an outline. That is why configuration files (Kubernetes, Ansible, CI pipelines, docker-compose) overwhelmingly use YAML, while data sent over the wire uses JSON. Converting between them lets each side of your workflow use the format that fits.
Common uses
- Turn a Kubernetes or docker-compose YAML manifest into JSON to feed an API or a script.
- Convert a JSON API response into YAML for a readable config file or fixture.
- Validate YAML — if it converts without an error, it is syntactically valid.
- Re-indent or reformat a messy file by round-tripping it through the converter.
FAQ
Is this YAML to JSON converter free?
Yes. It is completely free, needs no account, and runs entirely in your browser. Your data is never uploaded to a server.
Is my data safe?
Yes. All conversion happens locally in your browser with JavaScript. Nothing you paste leaves your device, so it is safe for sensitive config files and secrets.
Does it work offline?
Yes. Once the page has loaded, the converter runs without a network connection — the YAML parser ships with the page.
Does converting YAML to JSON keep my comments?
No. JSON has no concept of comments, so YAML comment lines (starting with #) are dropped. The data itself is preserved exactly.
Why did my version number 1.0 turn into 1?
Unquoted, 1.0 is read as a number and JSON drops the insignificant zero. Write "1.0" in quotes to keep it a string.
Are yes and no converted to true and false?
No. This converter follows YAML 1.2, where yes/no/on/off are strings. Use true or false for booleans.
Why do I get a parse error?
The most common causes are a tab used for indentation (YAML requires spaces), inconsistent indentation, or a missing colon or quote. The red error message points to the line.
Can I convert JSON back to YAML?
Yes — switch the toggle to JSON → YAML, paste valid JSON, and you get clean YAML out.
Can I convert multiple YAML documents at once?
Convert one document at a time. A single JSON value cannot represent a multi-document YAML stream (documents separated by ---).
Is there a size limit?
There is no fixed limit; you are bounded only by your browser's memory since everything runs locally. Very large files (tens of MB) may feel slow.