Skip to content
Tools

YAML to JSON Converter

Last updated:

Paste YAML and get the equivalent JSON, with anchors and aliases expanded and comments removed. If the YAML is invalid – usually an indentation or tab problem – you get the line and column of the error instead of a silent wrong result.

Runs in your browser: your YAML never leaves your device – nothing is uploaded, logged or stored on a server. How we protect your data

100% in-browserNothing is uploaded

Input

Loading editor…

Paste YAML here

or drop a file anywhere in this box. Everything stays in your browser.

Drop a file to load it

Output

Loading editor…

JSON appears here

Results update as you type.

How to use the YAML to JSON

  1. Paste YAML or drop a .yml/.yaml file.
  2. Read any parse error: it points to the line where indentation or syntax broke.
  3. Check the JSON for values whose type surprised you (see the table below).
  4. Copy or download the JSON.

Worked example

A deploy config using a comment and an anchor

YAML

# deploy config
app: web
replicas: 3
env:
  - name: LOG_LEVEL
    value: info
base: &region eu-west-1
backup: *region

JSON

{
  "app": "web",
  "replicas": 3,
  "env": [
    {
      "name": "LOG_LEVEL",
      "value": "info"
    }
  ],
  "base": "eu-west-1",
  "backup": "eu-west-1"
}

The comment is dropped (JSON has none) and the alias *region is replaced by the anchored value.

Unquoted YAML values and the JSON they produce

Results under the YAML 1.2 core schema. Older 1.1 parsers differ on some rows.

Unquoted YAML values and the JSON they produce
YAMLJSONWatch out
port: 80808080
debug: truetrue
answer: yes"yes"true in YAML 1.1 parsers
version: 1.101.1Quote it to keep "1.10"
value: ~nullEmpty value also means null
date: 2026-10-29"2026-10-29"Some parsers return a date object

Common YAML errors

Tabs are not allowed for indentation; replace them with spaces. A key indented one space less than its siblings ends the parent mapping early. A colon followed by a space inside an unquoted value, as in title: Note: read me, starts a new mapping – quote the value.

Multiple documents

A file can hold several YAML documents separated by ---, as Kubernetes manifests often do. JSON has a single root, so multi-document input converts to a JSON array with one element per document.

Custom tags such as !Ref in CloudFormation are not part of core YAML; they have no JSON equivalent and may be rejected or kept as plain values.

YAML to JSON FAQ

How do I convert YAML to JSON on the command line?

With yq v4: yq -o=json file.yaml. With Python and PyYAML: python -c 'import sys,yaml,json; print(json.dumps(yaml.safe_load(sys.stdin)))' < file.yaml.

Why does my YAML fail to parse?

Most often a tab used for indentation, inconsistent indent levels, or an unquoted value containing ": " or starting with a special character like @, * or &. The error line points to where the parser gave up.

What happens to YAML comments when converting to JSON?

They are removed. JSON has no comment syntax, so there is nowhere to keep them.

How are YAML anchors and aliases converted?

Each alias is replaced with a full copy of the anchored value, so the JSON may be larger than the YAML.

Is YAML a superset of JSON?

YAML 1.2 is designed to be, so JSON is valid YAML. The reverse is not true: comments, anchors and multiple documents have no JSON form.

Related tools