YAML to JSON

Convert YAML to JSON for APIs and code. Anchors and merge keys are expanded, and any YAML error is shown with its line and column.

Runs in your browser

YAML

JSON

Converted in this browser tab. Nothing is uploaded.

How to use the YAML to JSON

  1. Paste YAML or open a .yaml or .yml file.
  2. The JSON appears as you type.
  3. If the YAML is invalid, the error line is highlighted.
  4. Choose the JSON indent, then copy or download.

Example

Anchors and merge keys
Input
defaults: &d
  retries: 3
prod:
  <<: *d
  url: https://example.com
Result
{
  "defaults": {
    "retries": 3
  },
  "prod": {
    "retries": 3,
    "url": "https://example.com"
  }
}

What it does

Full YAML support
Block and flow styles, multi-line strings, anchors, aliases and << merge keys, using the yaml library.
Multiple documents
A file with several documents separated by --- becomes a JSON array with one item per document.
Protected against YAML bombs
Alias expansion is capped, so a "billion laughs" document stops with a message instead of freezing your browser.
Duplicate keys caught
A key that appears twice in the same mapping is reported as an error, because YAML does not allow it.

Frequently asked questions

Are comments kept?

No. JSON has no comments, so YAML comments are dropped.

Can I use this as a YAML validator?

Yes. If the YAML has a syntax error or a duplicate key, you get the message and the line and column of the problem.

Is anything I paste sent to a server?

No. It runs entirely in your browser. Nothing you paste or upload is sent, logged or stored.