YAML to JSON Converter

Paste YAML and click Convert to JSON. Anchors, aliases and << merge keys are resolved, and if the YAML has an error you see its line and column.

Editor (Formatted View)
1
Ready — paste or type YAML here
Viewer
Converted output will appear here
Ready

How to convert YAML to JSON

  1. Paste your YAML, open a .yaml or .yml file, or click Load Sample.
  2. Click Convert to JSON. The JSON appears on the right, indented with two spaces.
  3. Copy or download it. If the YAML has a mistake, the line turns red and the message explains what the parser expected.

How YAML maps to JSON

YAMLJSON
key: value blocksObject
- item listsArray
true, false, and also yes, no, on, offtrue or false
null, ~ or no value at all (key:)null
8080, 1.5Number
2026-01-05The string "2026-01-05", kept exactly as written
| block (keeps line breaks)String with \n between lines
> block (folds lines)String with the lines joined by spaces
&anchor and *aliasA full copy of the anchored value
<<: *defaultsThe keys of defaults merged into the object
Several documents separated by ---An array with one item per document
# commentsDropped, because JSON has no comments

Anchors and merge keys

Docker Compose files, CI pipelines and Rails configs often reuse settings with anchors. This YAML:

defaults: &defaults
  adapter: postgres
  pool: 5
development:
  <<: *defaults
  database: app_dev

becomes

{
  "defaults": { "adapter": "postgres", "pool": 5 },
  "development": { "adapter": "postgres", "pool": 5, "database": "app_dev" }
}

Some online converters leave a literal "<<" key in the JSON. Here the merge is applied, so the JSON is what your application actually sees.

Values that change type

YAML guesses types from how a value looks, and the guess isn't always what you meant:

If a value comes out different from what you expected, quoting it in the YAML is almost always the fix.

OpenAPI, Swagger and Kubernetes files

OpenAPI and Swagger specs are usually written in YAML, but some tools only import JSON. Paste the spec here, convert it and save the result as openapi.json. The same works for Kubernetes manifests: a file with several resources separated by --- becomes a JSON array with one object per resource.

Converting YAML to JSON in code

# Python (pip install pyyaml)
import json, yaml
with open('config.yaml') as f:
    print(json.dumps(yaml.safe_load(f), indent=2))

// Node.js (npm install js-yaml)
const yaml = require('js-yaml');
const json = JSON.stringify(yaml.load(fs.readFileSync('config.yaml', 'utf8')), null, 2);

# Command line with yq
yq -o=json config.yaml

Frequently asked questions

Is my YAML stored?

No. The YAML is sent to our server only to be converted and is not saved or logged. The result comes straight back to your browser.

Does it support anchors, aliases and merge keys?

Yes. &anchor and *alias are replaced with a copy of the value, and <<: *name merges that mapping's keys into the object, so the JSON matches what your application loads.

What happens to YAML comments?

They are dropped. JSON has no comment syntax, so there is nowhere to put them.

Why did yes or no turn into true or false?

YAML 1.1 parsers, which most tools still use, read yes, no, on and off as booleans. Put the value in quotes to keep it as text.

Can it convert a file with several documents?

Yes. Documents separated by --- become a JSON array with one item per document, in the same order.

Other tools

Share Content

Choose what to share and generate an instant link

🔥 One-time link Content deleted from server after first view
✉️
Uploading to server…