YAML to JSON Converter

Convert YAML config files into JSON. Anchors and merge keys are resolved, multi-document files become arrays, and errors show the line and column. Nothing is uploaded.

Loading the tool. It runs entirely in your browser...

How to convert YAML to JSON

Paste YAML or drop a .yml file onto the input and the JSON appears alongside it. The converter understands the parts of YAML that plain JSON cannot express and resolves them for you: anchors and aliases (&base and *base) are expanded, merge keys (<<: *base) are merged into the parent mapping, and comments are dropped because JSON has no place for them.

A file that contains several documents separated by ---, as Kubernetes manifests often do, is converted into a JSON array with one element per document. A single document stays a single value. Choose two spaces, four spaces or a minified result.

If the YAML is invalid you will see the first problem with its line and column, such as a tab used for indentation, inconsistent indent levels or a duplicate key. Fix it and the output updates as you type.

Worked example

YAML input:

defaults: &defaults
  retries: 3
  timeout: 30
service:
  <<: *defaults
  timeout: 60
  ports: [80, 443]

JSON output:

{
  "defaults": { "retries": 3, "timeout": 30 },
  "service": { "retries": 3, "timeout": 60, "ports": [80, 443] }
}

The service block inherited retries from the anchor and overrode timeout, exactly as a YAML consumer would see it.

Type surprises to expect

  • Unquoted values are typed: port: 80 is a number, debug: false a boolean and owner: null or owner: ~ null. Quote a value to force a string.
  • YAML 1.2 rules: yes, no, on and off are plain strings, not booleans as in YAML 1.1.
  • Dates: timestamps such as 2025-01-15 are kept as strings in the JSON.
  • To produce YAML from JSON, use the JSON to YAML converter.

Frequently asked questions

Does the converter resolve anchors and aliases?

Yes. Aliases are replaced by a copy of the anchored value, and merge keys are merged into the parent mapping, so the JSON contains the final, fully expanded data.

What happens to comments?

Comments are discarded, because JSON cannot represent them. Keep the original YAML if the comments matter.

Can I convert a file with several documents?

Yes. Documents separated by three dashes become the elements of a JSON array. A file with only one document produces that document directly.

Why does my YAML report an error about tabs?

YAML forbids tab characters for indentation. Replace them with spaces. The error message shows the line and column where the tab was found.