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, no sign-up and no ads.
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.
More Developers tools
- Base64, URL and HTML · Encode and decode in all three formats
- Hash generator · MD5 and SHA for text or files
- UUID generator · Unique identifiers instantly
- Strong passwords · With a strength meter
- JWT decoder · Read header, payload and expiry
- Regex tester · Highlighted matches and groups
- Colours and gradients · HEX, RGB, HSL, OKLCH, contrast and gradients
- CSS shadows · box-shadow with live preview