YAML to JSON
Convert YAML to JSON with 2-space, 4-space or tab indentation. Expands anchors and aliases, supports multiple documents and shows the line of any error.
About YAML to JSON
The YAML to JSON converter parses YAML, the format used by Kubernetes manifests, Docker Compose files, GitHub Actions workflows and OpenAPI specs, and writes the same data as JSON. Paste a .yaml or .yml file and the JSON appears as you type, indented with 2 spaces, 4 spaces or tabs.
Parsing uses the yaml library with YAML 1.2 rules, so values such as yes, on and 2026-01-01 stay strings, while true, 42 and null keep their types. Anchors and aliases are expanded, a file with several documents becomes a JSON array, and syntax errors are reported with line and column.
How to use YAML to JSON
- Paste YAML into the input box, or drop a .yaml or .yml file onto it.
- Choose 2 spaces, 4 spaces or Tabs for the JSON output.
- If the YAML does not parse, fix the error at the reported line and column.
- Copy the JSON or download it as a .json file.
Features
- Follows YAML 1.2 core schema typing, so yes, no, on and off remain strings.
- Expands anchors (&) and aliases (*) into full copies of the referenced data.
- Converts multi-document files separated by --- into a JSON array of documents.
- Reports syntax errors, such as bad indentation, with line and column.
- Writes values JSON cannot represent, such as .inf and .nan, as null.
Common uses
- Feeding a Kubernetes or Docker Compose file to a tool that only reads JSON.
- Checking how a CI workflow’s YAML is actually interpreted, including types and anchors.
- Converting an OpenAPI or Swagger spec from YAML to JSON.
- Debugging indentation problems in configuration files.
Tips
- Merge keys (<<: *anchor) are not part of YAML 1.2 and are not expanded; they appear as a literal "<<" key in the output. Copy the fields explicitly if the target expects them merged.
Frequently asked questions
What is the difference between JSON and YAML?
Both describe the same kinds of data: objects, arrays, strings, numbers, booleans and null. JSON uses braces, brackets and quotes and is easy for programs to produce; YAML relies on indentation, allows comments and is easier for people to edit. Every JSON document is also valid YAML 1.2.
Why does yes become a string and not true?
YAML 1.1 treated yes, no, on and off as booleans, which caused well-known surprises such as the country code NO turning into false. YAML 1.2, which this converter follows, only recognizes true and false. Older tools may still read these values differently.
Are YAML comments kept?
No. JSON has no comment syntax, so comments are discarded during conversion. Keep the YAML file as your source if the comments matter, and regenerate the JSON from it when it changes.
How are multiple YAML documents converted?
A file containing several documents separated by --- becomes a JSON array with one element per document, in order. A file with a single document becomes that document’s value directly, without a wrapping array.
Are anchors and aliases supported?
Yes. Each alias (*name) is replaced by a copy of the data defined at its anchor (&name), so the JSON contains the full values. Alias expansion is capped to protect the page from “billion laughs” style inputs that would expand to enormous sizes.
Can I convert YAML to JSON online for free without signing up?
Yes. Use this tool without an account or payment. Files are processed in your browser. Download the result after processing; supported formats and browser requirements are described above. Conversion can change quality, transparency or layout depending on the formats.
Is my input uploaded?
Tools run in your browser. Files, text and results are not uploaded to our servers and are cleared when you leave the tool.
Your privacy comes first
Tools run in your browser. Files, text and results are not uploaded to our servers and are cleared when you leave the tool.