JSON ↔ YAML Converter
Understand JSON ↔ YAML Converter
This converter moves the same data between JSON and YAML, the two formats most configuration files are written in.
How it works
Both formats describe the same three things — mappings, sequences, and scalars — so a conversion is a re-print rather than a translation. Going to YAML, structure becomes indentation instead of braces, and any string that would otherwise be read back as a number, a boolean, or null is quoted to keep it a string. Going to JSON, indentation becomes braces and brackets again, and comments are dropped because JSON has nowhere to put them.
When to use it
- Turning an API response into a YAML fixture for a test or a config file.
- Converting a Docker Compose or Kubernetes snippet to JSON so a script can read it with a plain JSON parser.
- Rewriting hand-written YAML as JSON to find the exact place a parser disagrees with you.
- Moving settings between two tools that read different formats.
Watch out for
- Comments do not survive the round trip. In a real config file the comments carry most of the documentation, and JSON has no way to represent them.
- In YAML 1.1 parsers — PyYAML by default, and a lot of older tooling — the unquoted values yes, no, on, and off are booleans, so a country code of NO becomes false. This converter follows YAML 1.2 and keeps them as strings, which means a value can look correct here and flip further down your pipeline. Quote them either way.
- The converter handles the shape most config files have: top-level keys, nested mappings, and simple lists. Anchors and aliases (&base, *base), block scalars (| and >), and multi-document files separated by --- are not carried through.
Not the right tool for: Round-tripping a Helm chart or any templated YAML. Converting to JSON and back drops the anchors and template syntax that make it a template.
Frequently Asked Questions
How to convert YAML to JSON?
Paste your YAML into the input, select "YAML → JSON", and click Convert. The tool parses YAML (including anchors and multi-line strings) and outputs formatted JSON. YAML 1.2 is used so "yes"/"no"/"on"/"off" are strings, not booleans — matching JSON semantics.
How to convert JSON to YAML?
Paste your JSON, select "JSON → YAML", and click Convert. All JSON types map to YAML equivalents: strings, numbers, booleans, null, objects (YAML mappings), and arrays (YAML sequences). Comments are not carried over since JSON has none.
What are common YAML parsing pitfalls when converting from JSON?
Country codes like "NO" and "ON" parse as booleans in YAML 1.1. Version strings like "1.2" parse as floats. Octal-looking numbers like "0755" parse as octal. Quote these values to preserve their string type.
How to Use JSON ↔ YAML Converter
- Paste or type your input in the input area above.
- The tool processes your input automatically or click Run.
- Copy or download the result using the action buttons.
- Use Ctrl+Enter to run quickly from the keyboard.