← Home

Data

YAML ⇄ JSON

Convert YAML to JSON and JSON to YAML, with anchors, multiple documents and errors with line and column.

How it works

YAML is the format of Kubernetes, Docker Compose, GitHub Actions, OpenAPI and plenty of configuration files; JSON is what APIs, jq and most languages expect. This tool converts between the two as you type.

In YAML → JSON, anchors (&name), aliases (*name) and merge keys (<<:) are resolved, types are kept (numbers, booleans, null) and, if the text has several documents separated by ---, you get an array with one entry per document. In JSON → YAML, the output uses block style and does not wrap long lines, so you can paste it straight into a config file.

If something is wrong, you see the message with its line and column: an unclosed list, bad indentation or a duplicate key. It is the quickest way to find out why kubectl apply or a CI workflow rejects a file.

When you switch direction, the output becomes the new input, so you can go back and forth. Pick 2 or 4 spaces of indentation to match your project.

Keep in mind that YAML comments do not exist in JSON and are lost in the conversion. Everything happens in your browser.

Examples

YAML config to JSON

Input
service: payments-api
replicas: 3
ports:
  - 8080
  - 9090
Output
{
  "service": "payments-api",
  "replicas": 3,
  "ports": [
    8080,
    9090
  ]
}

JSON to YAML

Input
{"env": {"LOG_LEVEL": "info", "FEATURE_PIX": true}}
Output
env:
  LOG_LEVEL: info
  FEATURE_PIX: true

Frequently asked questions

What happens to anchors and aliases?

They are resolved: an alias *img copies the value of the &img anchor, and merge keys <<: *base blend in the referenced map. The resulting JSON has no references.

What if the YAML has several documents?

If the text has several documents separated by ---, like a Kubernetes manifest with several resources, the result is a JSON array with one element per document.

Are comments lost?

Yes. JSON has no comments, so they are dropped going from YAML to JSON and cannot come back when converting to YAML again.

Is my config sent to a server?

No. The conversion uses the yaml library inside your browser; neither the YAML nor the JSON leaves the tab.