JSON to YAML Converter
Convert JSON to YAML and YAML to JSON.
About this tool
Paste JSON or YAML and get the other one back. The direction is detected automatically, and parse errors point to the line that broke. Handy for Kubernetes manifests, Docker Compose files and CI configs.
How to use it
- Paste JSON or YAML into the Input box.
- Leave the direction on Detect, or force JSON to YAML or YAML to JSON.
- Pick 2 or 4 spaces of indentation.
- Copy the output, or click Use output as input to convert it back.
Questions
- Is YAML a superset of JSON?
- Practically yes: since YAML 1.2, almost any valid JSON document is also valid YAML. The reverse is not true, because YAML has comments, anchors and multi-line strings that JSON cannot express.
- What happens to YAML comments when converting to JSON?
- They are dropped, because JSON has no comments. Keep the YAML file as your source of truth if the comments matter.
- Can I convert a file with several YAML documents separated by ---?
- Yes. Each document becomes one element of a JSON array, and the status line says how many documents were found.
- Why does “no” turn into false?
- Older YAML 1.1 parsers treat words like yes, no, on and off as booleans. This tool uses YAML 1.2 rules where only true and false are booleans, but quote such values if other tools will read the file.
- Are YAML dates converted to JSON dates?
- JSON has no date type, so values like 2026-01-12 or 2026-01-12T10:00:00Z stay plain strings, which is what most programs expect. Some YAML 1.1 parsers, such as PyYAML, turn the same values into date objects, so the result of loading the file can differ between tools.
- Why does a file mode like 0755 become 755?
- Under YAML 1.2 rules a leading zero does not mean octal, so 0755 is the decimal number 755. Octal needs the 0o prefix: 0o755 becomes 493. Older YAML 1.1 tools read 0755 as octal, so quote file modes, as in mode: "0755", whenever the reading tool matters.
- Why are some strings quoted in the YAML output?
- Strings that would be read back as another type get quotes, so the value survives a round trip. The JSON string "true" becomes "true" in YAML, not the boolean true, and the same applies to "123", "null", "1.10" and text containing a colon followed by a space. Ordinary strings stay unquoted.
JSON vs YAML: when to use which
JSON and YAML describe the same data: objects, arrays, strings, numbers, booleans and null. JSON is strict and fast to parse, which makes it the default for APIs, package.json and data passed between programs. YAML is designed for people editing files by hand: few braces or quotes, comments with #, and multi-line strings. That is why Kubernetes manifests, Docker Compose files, GitHub Actions workflows and Ansible playbooks are written in YAML.
A practical rule: when a program writes a file and another program reads it, use JSON. When a person maintains the file, YAML is easier to read and review. Many tools accept both, and kubectl apply takes either format. A JSON to YAML converter is handy when a CLI or an API gives you JSON, for example kubectl get deployment web -o json, and you want a readable YAML copy to keep in Git.
How to fix YAML indentation and parse errors
YAML uses indentation to show structure, so most parse errors are whitespace problems. Tabs are not allowed for indentation at all, and the parser reports “Tabs are not allowed as indentation”. Items of one list and keys of one map must start in the same column, and a nested value must be indented further than its key. The error names the line and column where parsing stopped, which is usually at or just after the real mistake.
A colon followed by a space inside an unquoted value is another classic YAML error. url: http://example.com is fine, but title: Note: read this fails, because the second colon starts a nested mapping. Quote such values, as in title: "Note: read this". Values starting with @ or a backtick need quotes too, and so do strings that look like numbers, such as version: "1.10", which would otherwise become the number 1.1.
What happens to YAML anchors when converting to JSON?
YAML lets you define a block once with an anchor such as &defaults and reuse it elsewhere with the alias *defaults. JSON has no equivalent, so during YAML to JSON conversion every alias is replaced by a full copy of the anchored value. The JSON is correct but longer, and the link between the copies is lost. Merge keys written as <<: *defaults are not part of YAML 1.2 and stay in the JSON as a key named <<.
Before committing a converted file, check the round trip. Click Use output as input to convert the result back, then compare it with the original in Text Diff. The values should survive unchanged, while the presentation may differ: comments disappear, anchors are expanded and quoting can change. Kubernetes and most YAML style guides indent with 2 spaces, which is the default here, and 4 spaces is available for teams that prefer it.
Something not working, or a result looks wrong? Report a problem with this tool