YAML ⇄ JSON
Convert in both directions
No database: AIMRAN doesn't store your files, text or results
What is YAML ⇄ JSON?
YAML and JSON are two formats for storing data and configuration. YAML is common in Docker Compose, Kubernetes or GitHub Actions, and JSON in APIs and web apps. This tool converts from one to the other in both directions.
If there's an error in the file, such as wrong indentation or a duplicate key, it explains it in plain English so you can fix it quickly.
How to use it
- Choose the conversion: YAML to JSON or JSON to YAML.
- Paste the content or open a file.
- Choose 2 or 4-space indentation.
- Turn on “Multiple documents as array” if your YAML has blocks separated by ---.
- Copy or download the result.
Advantages
- Two-way conversion with a button to swap direction.
- Supports multi-document YAML files.
- Syntax errors explained in plain English.
- Free, with no sign-up.
Use cases
- Convert a docker-compose.yml or a Kubernetes manifest to JSON to process it with jq or a script.
- Turn a JSON config into YAML for a GitHub Actions workflow or an Ansible file.
- Find the indentation error or duplicate key that breaks a YAML config file.
- Convert a YAML file with several documents separated by --- into a JSON array.
Technical details
YAML parsing and generation use the yaml library (eemeli/yaml), compatible with YAML 1.2, and JSON is serialized with JSON.stringify. Files with multiple documents separated by --- can be converted into a JSON array; if the option is off, a warning says only the first is used. When converting to YAML, line width isn't limited, so long strings aren't split. Parser errors are explained in plain English: wrong indentation, tab used for indentation (YAML only allows spaces), duplicate key, invalid alias or missing closing character, among others. YAML anchors and aliases are resolved when converting to JSON. Files up to 20 MB can be opened.
Frequently asked questions
What's the difference between YAML and JSON?
They represent the same data. JSON uses braces, brackets and quotes; YAML uses indentation and is easier to read and write by hand, which is why it's used for configuration.
Is all JSON valid YAML?
Yes. Since YAML 1.2, JSON is practically a subset of YAML, so a JSON file can usually be read as YAML.
Why does my YAML give a tab error?
YAML doesn't allow tabs for indentation, only spaces. Replace the tabs with 2 or 4 spaces.
What happens to YAML comments when converting to JSON?
They're lost, because JSON doesn't support comments.
Can I convert a docker-compose.yml to JSON?
Yes. Paste the content or open the file and you'll get the equivalent JSON.
Blog guides
Related tools
- JSON · Format, validate and minify
- JSON to TypeScript · Interfaces, types and Zod schemas
- Minifier · CSS, JS and HTML
- Excel, CSV and JSON · Viewer and converter between formats
- SQL formatter · Format or minify queries
- Base64, URL and HTML · Encode and decode in all three formats