YAML to JSON Converter
Convert YAML to JSON online: paste a Kubernetes manifest, a Docker Compose file or any YAML config and get clean, formatted JSON instantly. Anchors and merge keys are resolved, and if the YAML is invalid you get the exact line and column of the error.
Runs in your browser — nothing is uploaded.Your YAML is converted on your device, so configs with secrets are safe to paste.
Learn more
YAML vs JSON vs TOML: Which Config Format Should You Use?
YAML, JSON, and TOML all store structured data but have different design philosophies. Learn when to use each format, how they compare, and the infamous YAML Norway problem.
YAML for Developers: Common Indentation Errors and How to Debug Your Config
The most common YAML mistakes developers make — tabs vs spaces, unquoted booleans, inconsistent indentation — and how to read parser error messages with line/column context.
JSON vs XML: Which Should You Use for Your API?
JSON and XML both represent structured data, but they have very different strengths. Learn when to use each format, how they compare in size and verbosity, and which is right for your use case.
How to use the YAML to JSON converter
- Paste or type YAML into the left editor. Conversion happens on every keystroke.
- Pick 2 or 4 spaces of indentation for the JSON output.
- If there is an error, fix the line it points to; otherwise copy the JSON or download it as a file.
Worked example: a Docker Compose snippet
This YAML uses a comment, an anchor with a merge key, and a few unquoted values:
# docker-compose.yml
x-defaults: &defaults
restart: unless-stopped
services:
api:
<<: *defaults
image: myorg/api:1.10
environment:
DEBUG: no
VERSION: 1.10
RELEASE_DATE: 2026-10-16The converter produces:
{
"x-defaults": {
"restart": "unless-stopped"
},
"services": {
"api": {
"restart": "unless-stopped",
"image": "myorg/api:1.10",
"environment": {
"DEBUG": "no",
"VERSION": 1.1,
"RELEASE_DATE": "2026-10-16T00:00:00.000Z"
}
}
}
}The comment is gone, the <<: *defaults merge was expanded into restart, and the two unquoted values changed: VERSION became the number 1.1 and the date became a full UTC timestamp. image stayed intact because myorg/api:1.10 isn't a valid number. If any of these values must stay exactly as written, quote them in the YAML.
How YAML types become JSON types
| YAML | JSON output | Why |
|---|---|---|
| DEBUG: no | "DEBUG": "no" | String in YAML 1.2. PyYAML (1.1) would give false. |
| VERSION: 1.10 | "VERSION": 1.1 | A number — the trailing zero is lost. Quote version numbers. |
| RELEASE: 2026-10-16 | "RELEASE": "2026-10-16T00:00:00.000Z" | Parsed as a timestamp, written as ISO 8601 UTC. |
| MODE: 012 | "MODE": 12 | Decimal 12 in YAML 1.2; YAML 1.1 parsers read octal 10. |
| PORT: "8080" | "PORT": "8080" | Quoted, so it stays a string. |
| VALUE: ~ | "VALUE": null | ~ and an empty value both mean null. |
Common YAML errors when converting
| Error message | What to fix |
|---|---|
| tab characters must not be used in indentation | YAML indentation must use spaces. Replace tabs (configure your editor to insert spaces for .yml files). |
| bad indentation of a mapping entry | A key is indented differently from its siblings, or a list item is less indented than its parent key. Line up keys at the same level exactly. |
| expected a single document in the stream, but found more | The file has --- separators. Convert each document separately. |
| duplicated mapping key | The same key appears twice at the same level. Later tools may silently keep one — remove the duplicate. |
For more on indentation rules and these exact error messages, see YAML for developers, or check a file before converting with the YAML validator.
Why YAML conversion should happen in your browser
The YAML people convert is rarely harmless: Kubernetes Secrets, Helm values.yaml, GitHub Actions workflows and Compose files with database passwords in environment. A converter that processes or saves input on a server keeps a copy you can't delete. That risk is real — JSONFormatter and CodeBeautify exposed more than 80,000 saved pastes (about 5 GB) that included API keys and cloud credentials. Read how the JSONFormatter and CodeBeautify leak happened. This converter runs js-yaml in the page itself, so your YAML never leaves your machine.
Related Tools
Frequently Asked Questions
How do I convert YAML to JSON online?▾
Paste your YAML into the left editor. The converter parses it as you type and shows formatted JSON on the right; choose 2 or 4 spaces of indentation, then copy or download the result as a .json file. If the YAML is invalid, the error message shows the line and column of the problem instead. Nothing is uploaded — the conversion runs in your browser with js-yaml.
How do I convert YAML to JSON on the command line?▾
With yq (v4): yq -o=json file.yaml > file.json. With Python and PyYAML: python3 -c 'import sys, yaml, json; print(json.dumps(yaml.safe_load(sys.stdin), indent=2))' < file.yaml. With Node.js and js-yaml: npx js-yaml file.yaml. Be aware that PyYAML follows YAML 1.1, so it turns no/yes/on/off into booleans, while js-yaml and yq follow YAML 1.2 and keep them as strings.
Why did my date turn into a timestamp like 2026-10-16T00:00:00.000Z?▾
An unquoted value like 2026-10-16 matches YAML's timestamp type, so js-yaml parses it as a date, and JSON has no date type — it is written as an ISO 8601 string in UTC. If you want the literal text, quote it in the YAML: release_date: "2026-10-16".
Can I convert a Kubernetes YAML file with multiple documents?▾
Not in one go. Kubernetes manifests often contain several documents separated by ---, and JSON has no way to hold several top-level values in one document, so this converter reports 'expected a single document in the stream, but found more'. Paste one document at a time, or on the command line use yq -o=json file.yaml, which prints one JSON object per document.
Is it safe to convert YAML that contains secrets?▾
Here, yes: the conversion happens in your browser and no request is made with your YAML. That matters because YAML files are where secrets live — Kubernetes Secret manifests (whose base64 values are encoding, not encryption), Helm values files, CI pipelines and docker-compose environment blocks. Your input is kept in this browser's localStorage so it survives a reload; the trash button clears it.
What YAML features are permanently lost when converting to JSON?▾
JSON has no equivalent for: (1) comments — all # comments are stripped silently; (2) anchors and aliases — &anchor / *alias pairs are resolved (the referenced value is inlined) so the deduplication is lost; (3) block scalars — multi-line | (literal) and > (folded) strings are collapsed into a single-line JSON string with \n characters; (4) custom type tags — these are either stripped or cause a parse error. If you need to preserve comments or anchors for re-editing, keep your canonical source in YAML and treat JSON as a read-only export.
Can valid YAML fail to convert to JSON?▾
Yes. YAML allows non-string keys — you can have an integer, boolean, or even an object as a map key. JSON only allows string keys. A YAML document with {42: value} (integer key) will either fail conversion or produce {"42": value} with the key coerced to a string. YAML also allows multiple documents in one file (separated by ---), which JSON cannot represent as a single value. YAML with circular references (created via anchors) cannot be serialized to JSON at all.
What is the difference between YAML 1.1 and YAML 1.2, and why does it matter?▾
YAML 1.1 (2005) has an extended set of boolean aliases (yes, no, on, off, y, n, true, false — case-insensitive), uses different timestamp format, and interprets octal literals with a leading 0. YAML 1.2 (2009) reduced booleans to only true and false and aligned more closely with JSON semantics. Many widely-used libraries (PyYAML, Go's yaml.v2) still default to YAML 1.1. If a converter uses a 1.1 parser, No in your YAML becomes false in JSON — the Norway problem that silently broke many systems. This converter uses js-yaml, which follows YAML 1.2, so no stays the string "no".