YAML to JSON & JSON to YAML
Convert YAML to JSON and JSON to YAML with error positions, expanded anchors and multi-document support.
Runs in your browser. Nothing is uploaded.
What is YAML to JSON & JSON to YAML?
YAML is the human-friendly data format used for configuration files: Docker Compose, Kubernetes manifests, GitHub Actions workflows, OpenAPI specs and many application settings. JSON is the strict format that APIs and programs exchange. They describe the same kinds of data, objects, lists, text, numbers, true and false and null, so you often need to move from one to the other: turn a config file into JSON to feed a tool or an API, or write JSON as YAML to put it in a config file.
This YAML to JSON converter reads YAML 1.2 and tells you exactly where a mistake is, with the line and column of the problem, and it rejects duplicate keys instead of silently dropping one. Features that JSON cannot express are handled openly: anchors, aliases and merge keys are expanded into plain values, a file with several documents separated by --- becomes a JSON array, and comments are dropped with a note so you know they are gone. Text such as dates and version numbers stays text, and strings that look like numbers or true and false are quoted when you convert JSON to YAML so they come back unchanged.
Choose a 2 or 4 space indent, sort keys alphabetically if you want a stable order, swap the output back into the input to convert in the other direction, or open a file from your computer and download the result. Everything runs in your browser and large files are handled in a background worker, so your configuration, which often contains secrets, is never uploaded.
How to use
- Choose YAML to JSON or JSON to YAML, then paste your data or open a file.
- Pick a 2 or 4 space indent and tick Sort keys if you want alphabetical order.
- Read the result on the right. Notes under it tell you if comments were dropped, anchors expanded or several documents joined into an array.
- If the input has a mistake, the message gives the line and column to fix.
- Click Copy result or Download, or click Swap to convert the result back.
Example
Input
name: web ports: - 80 - 443 debug: false
Output
{
"name": "web",
"ports": [
80,
443
],
"debug": false
}Frequently asked questions
- What happens to comments in my YAML?
- JSON has no comments, so they are dropped, and the tool tells you when that happened. Converting back from JSON cannot restore them.
- What are anchors and aliases, and what happens to them?
- An anchor (&name) labels a value and an alias (*name) reuses it, and a merge key (<<) copies a whole mapping. JSON has no such feature, so they are expanded into plain repeated values.
- Why does my file with several --- sections become an array?
- Each section is a separate YAML document. JSON holds one value, so the documents are put in an array in order. A single document stays as itself.
- Why did a string get quotes when I converted JSON to YAML?
- In YAML an unquoted yes, true, null or 123 is read as a boolean, null or number. A JSON string with that text is quoted so it stays a string when the YAML is read back.
Related tools
- JSON Formatter & ValidatorFormat, minify and validate JSON online with line-accurate error messages.
- CSV to JSON & JSON to CSVConvert CSV to JSON and JSON to CSV with delimiter detection and nested JSON flattening.
- JSON DiffCompare two JSON documents and see every added, removed and changed value by path.
- Text Diff CheckerCompare two texts online and see added and removed lines side by side.