DevFormatter

YAML to JSON Converter

Instantly convert YAML to formatted JSON — anchors expanded, all in your browser, no server, no signup.

Our YAML Formatter converts YAML to JSON in one click — paste your YAML, then click → JSON from the Convert dropdown in the toolbar.
Open YAML to JSON Converter →

How YAML to JSON Conversion Works

The converter parses your YAML using js-yaml v5 with the YAML 1.2 Core schema, producing a JavaScript object. It then serializes that object to formatted JSON using JSON.stringify() with 2-space indentation.

YAML mappings become JSON objects, sequences become arrays, and scalars map to their JSON equivalents. YAML-specific features are resolved during parsing: comments are discarded (JSON has no comment syntax), and anchors and aliases are expanded into their full values.

Example:

YAML input

name: Alice
roles:
  - admin
  - user
active: true

JSON output

{
  "name": "Alice",
  "roles": [
    "admin",
    "user"
  ],
  "active": true
}

Frequently Asked Questions

How does YAML to JSON conversion work?
The converter parses your YAML using js-yaml v5 with the YAML 1.2 Core schema, which produces a JavaScript object. It then serializes that object to formatted JSON using JSON.stringify() with 2-space indentation. YAML mappings become JSON objects, sequences become arrays, and all scalar types map to their JSON equivalents.
What YAML features are lost during conversion?
Comments are discarded — JSON has no comment syntax. Anchors and aliases are expanded into their full values. Multi-line string styles (literal block |, folded >) are converted to regular JSON strings. The resulting JSON contains only the data, not any YAML formatting metadata.
What is the difference between YAML 1.1 and YAML 1.2 parsing?
YAML 1.1 parsers (PyYAML, Docker Compose, GitHub Actions) convert bare yes/no/on/off to booleans and time values like 22:30 to integers. YAML 1.2 parsers (js-yaml v5, used by this tool) do not — only true/false are booleans. If your YAML was written for a YAML 1.1 environment, use the Fix YAML 1.1 Risks button in the YAML Formatter before converting.
Is my data sent to a server?
No. The conversion runs entirely in your browser using js-yaml v5. Your data never leaves your machine.
Can I convert YAML to JSON in Python?
Yes: import yaml, json; data = yaml.safe_load(yaml_string); json_str = json.dumps(data, indent=2). Note that yaml.safe_load uses YAML 1.1 rules — bare yes/no/on/off become Python True/False. For YAML 1.2 behaviour, use ruamel.yaml instead.

Related Tools

Other free developer tools available on DevFormatter.