YAML ⇄ JSON
Convert YAML to JSON and JSON to YAML instantly with validation and clear error messages. Ideal for Kubernetes, Docker Compose and CI configs.
What is the YAML to JSON Converter?
YAML and JSON describe the same data — maps, lists, strings, numbers, booleans and null — but YAML is written for people (indentation, comments, anchors) while JSON is what APIs, browsers and most tooling consume. This converter parses YAML with the spec-compliant yaml library and writes standard JSON, or turns JSON into clean, idiomatic YAML for Kubernetes manifests, Docker Compose files, GitHub Actions workflows, Helm values and other configuration.
YAML features are resolved the way real tools resolve them: anchors (&name) and aliases (*name) are expanded, << merge keys are applied with local keys taking precedence, block scalars (| and >) keep their line breaks, and files with several documents separated by --- become a JSON array. Errors are reported with the exact line and column plus a source excerpt — duplicate keys, tabs used for indentation, unclosed brackets and bad indentation are all caught. Alias expansion is capped, so a malicious “billion laughs” file is rejected in milliseconds instead of freezing your browser. Integers larger than 2^53 keep all their digits.
When writing YAML you can choose 2- or 4-space indentation, line folding, quote style, key sorting and whether list items are indented. “YAML 1.1-safe quoting” (on by default) quotes strings such as yes, no, on, off, 0777 or 2001-12-14, which YAML 1.1 parsers like PyYAML or older Go libraries would otherwise read as booleans, octal numbers or dates. Everything runs locally in your browser — nothing is uploaded.
Frequently asked questions
- What is the difference between YAML 1.1 and YAML 1.2?
- YAML 1.2 (2009) aligned YAML with JSON: only true/false are booleans and 0777 is a decimal number. YAML 1.1 also treats yes/no/on/off/y/n as booleans, reads 0777 as octal and 2001-12-14 as a timestamp — the source of the “Norway problem”, where the country code NO becomes false. Pick the version that matches the tool that will read your file.
- Why does the GitHub Actions key “on” turn into “true”?
- Only in YAML 1.1 mode, where on is a boolean. GitHub Actions itself reads on as a string, which is what the default YAML 1.2 mode shows. When converting JSON back to YAML, the 1.1-safe option quotes it as "on" so every parser agrees.
- Are anchors, aliases and << merge keys supported?
- Yes. Aliases are replaced by a copy of the anchored value, and << merges one or more anchored maps into the current map, with keys written locally overriding merged ones — exactly how Docker Compose x- extension blocks are meant to work. The JSON output contains the fully expanded data.
- How are multiple YAML documents in one file handled?
- A file containing several documents separated by --- (common for Kubernetes manifests) is converted to a JSON array with one element per document, and a notice tells you how many were found. In the other direction, enable “Array → multiple documents” to write each array item as its own document.
- Is it safe to paste untrusted YAML?
- Yes. Parsing happens locally, no custom tags or code are executed, and alias expansion is limited (1,000 weighted references), so exponential “billion laughs” payloads are rejected instead of exhausting memory.
- Why are comments missing from the JSON output?
- JSON has no comment syntax, so YAML comments cannot be carried over. Converting back to YAML produces equivalent data, but formatting choices such as comments, anchors and flow vs. block style are not preserved.
Related tools
- Base64 EncoderEncode and decode Base64 for text and files, with URL-safe mode, data URIs, file type detection and image preview. Fast, private and offline.
- Timestamp ConverterConvert Unix epoch timestamps (seconds or milliseconds) to human-readable dates in any time zone, and dates back to timestamps.
- Number Base ConverterConvert numbers between binary, octal, decimal, hexadecimal and any base from 2 to 36, including arbitrarily large integers.
- JSON ⇄ CSVConvert JSON arrays to CSV and CSV back to JSON with custom delimiters, header detection, nested-field flattening and file download.
- CSS Unit ConverterConvert CSS units between px, rem, em, vw, vh and percentages with a configurable root font size and viewport.
- JSON FormatterFormat, validate, minify and explore JSON with precise error locations. Your data never leaves the browser.