📄 JSON to YAML & YAML to JSON Converter
A JSON to YAML converter that runs both ways in your browser, covering implicit typing: why 1.20 becomes 1.2 and unquoted NO can become false.
YAML Output (Kubernetes / Docker Ready)
What JSON to YAML & YAML to JSON Converter Does
YAML is a superset of JSON — any valid JSON document is also valid YAML, which this tool confirms by round-tripping it. The conversion that matters is the other direction: turning JSON's explicit punctuation into YAML's indentation-based structure.
YAML is more readable, which is why Kubernetes manifests, GitHub Actions workflows, Docker Compose files and OpenAPI specifications use it. It is also considerably more dangerous, because YAML guesses types from unquoted text and JSON never does.
That guessing is the source of every surprising YAML bug. A value that looks like a number, a date, a boolean or a time gets converted to one, and the string you wrote is gone.
How to Use JSON to YAML & YAML to JSON Converter
- Paste your JSON code into the text area
- View formatted YAML output in real-time
- Click Copy YAML for your Kubernetes or GitHub Actions configuration
Implicit Typing — What Unquoted Values Become
Verified locally against a YAML 1.2 core-schema parser. Results marked (1.1) follow the older schema still used by several widely-deployed parsers.
| You write | YAML 1.2 core | YAML 1.1 schema | Problem |
|---|---|---|---|
| version: 1.20 | number 1.2 | number 1.2 | Trailing zero lost from a version string — verified |
| octal: 0755 | number 755 | number 493 | A file mode read as decimal, or as octal, depending on parser |
| country: no | string "no" | boolean false | The "Norway problem" — country code NO becomes false |
| answer: yes | string "yes" | boolean true | Same class of bug |
| flag: off | string "off" | boolean false | Same class of bug |
| time: 12:30 | string "12:30" | number 750 (sexagesimal) | A time read as base-60 |
| value: ~ | null | null | Tilde is null, not a tilde character |
| empty: | null | null | An empty value is null, not an empty string |
JSON and YAML Compared
| JSON | YAML | |
|---|---|---|
| Comments | Not supported | # to end of line |
| Structure | Braces and brackets | Indentation (spaces only, never tabs) |
| Typing | Explicit — quoted is a string | Implicit — inferred from the text |
| Multi-line strings | Escaped \n only | Literal (|) and folded (>) blocks |
| Anchors and references | None | &anchor and *reference for reuse |
| Multiple documents | One per file | Separated by --- |
| Parsing risk | Low | Higher — some loaders can instantiate objects |
Where Each Is Used
| Format | Typical use |
|---|---|
| YAML | Kubernetes, GitHub Actions, Docker Compose, Ansible, OpenAPI specs, CI config |
| JSON | APIs, package manifests, browser storage, machine-to-machine data |
| Rule of thumb | YAML where humans write and edit it; JSON where machines exchange it |
How to Read Your Result
Quote anything that must stay a string
Version numbers, country codes, phone numbers, file modes, times and anything with leading zeros should be quoted in YAML. "1.20" stays a string; 1.20 becomes the number 1.2 and your version comparison breaks. This single habit prevents most YAML data bugs.
Tabs are a syntax error
YAML forbids tab characters for indentation, unconditionally. An editor configured to insert tabs will produce files that fail to parse with an error pointing at a line that looks perfectly fine. Configure spaces for .yml and .yaml files.
Use safe loading
Some YAML libraries can construct arbitrary objects from tags in the document, which turns loading an untrusted file into code execution. Python's yaml.load was the well-known example and now defaults to safe behavior. Use the safe loader explicitly for anything you did not write.
JSON is already valid YAML
Confirmed by round-tripping: a YAML parser reads a JSON document unchanged. That means you can paste JSON into a YAML file and it will parse — useful when embedding a compact structure inside an otherwise indented document, though it reads poorly.
Limitations & Accuracy Notes
- YAML comments cannot survive a conversion from JSON, because JSON has no comments to carry. Converting YAML to JSON and back loses every comment in the file.
- Anchors and aliases are expanded during conversion. The output is correct but larger, and the deduplication the original author intended is gone.
- Implicit typing behavior differs between YAML 1.1 and 1.2 and between parsers. The table above reports a 1.2 core-schema parser, verified locally; check your own consumer if the distinction matters.
- Key order is preserved in the output but has no formal meaning in either format.
- This handles data structures, not YAML's more exotic features — custom tags, complex mapping keys and multi-document streams may not round-trip.
Frequently Asked Questions
Why is YAML used over JSON in DevOps?
Is the conversion performed securely in browser?
Is YAML a superset of JSON?
What is the Norway problem?
Why does my YAML break after editing?
Should I quote strings in YAML?
Why use YAML over JSON for configuration?
Is my data uploaded?
References & Further Reading
- YAML 1.2 Specification — The current spec, including the core schema and its resolution rules
- RFC 8259 — The JSON Data Interchange Format — The source format