YAML to JSON converter — see exactly how your YAML is parsed

Paste YAML, such as a Kubernetes manifest, GitHub Actions workflow or Docker Compose file, and get the same data as JSON, with parse errors shown by line and column.

Live demo · real result from this tool
Indent

JSON

{  "name": "deploy",  "on": {    "push": {      "branches": [        "main"      ]    }  },  "jobs": {    "build": {      "runs-on": "ubuntu-latest",      "steps": [        {          "uses": "actions/checkout@v4"        },        {          "run": "npm ci"        },        {          "run": "npm test"
        }
      ]
    }
  }
}

Processed on your device — nothing is uploaded.

How to use the YAML to JSON converter

  1. Paste YAML into the Input box. The sample is a small GitHub Actions workflow.
  2. Choose the Indent: 2 spaces, 4 spaces or Compact (one line).
  3. Copy the JSON or download it as data.json.
  4. If the YAML is invalid, the message gives the line and column to fix.

What it does and when to use it

YAML hides structure in indentation, so it is easy to put a key one level too deep or turn a list into a string. Converting to JSON shows the parsed result with explicit braces and brackets, which is the fastest way to debug a CI workflow, Helm values file or OpenAPI spec that “looks right” but behaves wrongly. You also need JSON when an API, a test fixture or a tool like jq will not accept YAML.

To convert back, use JSON to YAML. To tidy YAML without leaving the format, try the YAML formatter. For TOML configs there is TOML to JSON.

How it works

The tool loads the js-yaml library in your browser and reads every document in the input with YAML 1.2 core rules:

  • true/false become booleans, null, ~ and empty values become null.
  • Plain digits and decimals become numbers; everything else unquoted is a string, including dates like 2024-05-01.
  • Anchors (&name) and aliases (*name) are expanded.
  • One document gives one JSON value; several give an array.

Then JSON.stringify writes the result with your indent. Nothing is uploaded.

Worked examples

These are the tool’s own outputs.

The workflow sample. The on: key stays the string "on" rather than becoming true, and branches: [main] becomes a one-item array:

  "on": {
    "push": {
      "branches": [
        "main"
      ]

Values that change type. This input:

version: 1.10
country: NO
enabled: yes
port: 08080
when: 2024-05-01
empty:
zip: "02134"

gives "version": 1.1, "country": "NO", "enabled": "yes", "port": 8080, "when": "2024-05-01", "empty": null and "zip": "02134". Only the quoted ZIP code keeps its leading zero.

A merge key, compact output. With defaults: &d and <<: *d under prod, the compact JSON is {"defaults":{"retries":3},"prod":{"retries":3,"host":"db.example.com"}}. The defaults are merged into prod.

Bad indentation. key: value followed by bad: indent fails with “Invalid YAML at line 2, column 6: bad indentation of a mapping entry.”

Limits and tips

  • Merge keys are applied, as shown above, so Docker Compose and CI files that rely on them come out flattened.
  • Long numbers lose precision. id: 12345678901234567890 comes out as 12345678901234567000; quote long IDs.
  • Custom tags such as !Ref in CloudFormation stop the run with “unknown scalar tag”.

Frequently asked questions

Why do yes, no and on stay as strings?
The converter follows YAML 1.2, where only true and false are booleans. Older YAML 1.1 tools also read yes, no, on and off as booleans, which famously turned the country code NO into false. If your program uses a YAML 1.1 parser, it may read these values differently.
Why did 1.10 become 1.1 and 08080 become 8080?
Unquoted, both are numbers in YAML 1.2, and JSON numbers have no trailing or leading zeros. Quote values like versions, ZIP codes and phone numbers in your YAML to keep them as text.
Are anchors and aliases supported?
Yes. An alias such as *d is replaced by a copy of the anchored value, and the << merge key is applied: the anchored keys are copied into the mapping, and keys written next to << win.
What happens to comments?
They are dropped. JSON has no comments and the YAML parser does not keep them.
Can I convert a file with several documents?
Yes. Documents separated by --- lines become a JSON array with one element per document. A single document becomes a plain object.

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close