Free Converter

YAML to JSON Converter

Fast and secure YAML to JSON conversion. Perfect for configuration files and data analysis.

Or

About YAML to JSON Conversion

YAML and JSON are closely related formats — JSON is technically a strict subset of YAML 1.2 — and converting between them is usually straightforward. YAML adds human-friendly features that JSON lacks: comments, multi-line strings without escaping, anchor and alias references, more flexible quoting, and indentation-based structure that resembles natural document layout. This makes YAML the popular choice for configuration files (Kubernetes manifests, GitHub Actions workflows, Docker Compose) while JSON dominates API payloads.

Converting YAML to JSON usually means giving up YAML's human-friendly extras in exchange for a format that machines parse more easily and that is the lingua franca of HTTP APIs. Comments are dropped (JSON has none). Anchor references are resolved into their referent values. Multi-line strings collapse to standard JSON strings with embedded newlines.

This converter parses YAML using js-yaml, the most widely used YAML library in JavaScript. Output is generated using JSON.stringify with optional indentation. The conversion handles all standard YAML 1.2 syntax including flow style, block style, scalars, sequences, mappings, anchors, aliases, and the standard tag types.

Why Convert YAML to JSON

Most APIs and many programming environments expect JSON. Configuration files written in YAML need to be converted to JSON when integrating with code or services that only accept JSON. Tooling for JSON is also more abundant: jq, JSON Path, JSON Schema, and a wide ecosystem of validators and transformers all assume JSON input.

JSON is also unambiguous in ways YAML is not. YAML's flexibility creates parsing surprises — strings like 'no' parsing as boolean false in YAML 1.1, version strings parsing as floats, indentation errors producing silent structural changes. Converting to JSON freezes the data into a less-ambiguous form.

How to Convert YAML to JSON

Paste YAML, get JSON.

  1. Add your YAML: Paste YAML text into the input area or drop a .yml/.yaml file. js-yaml accepts the full YAML 1.2 syntax.
  2. Convert: js-yaml parses the YAML into a JavaScript object, and JSON.stringify serializes it with two-space indentation. Comments are dropped, anchors are resolved, and special YAML types (timestamps, binary data) are converted to JSON-compatible representations.
  3. Review the result: Confirm that the JSON structure matches what you expected. Compare against the source YAML to spot any places where YAML's loose typing produced unexpected JSON values.
  4. Download or copy: Save as .json or copy to clipboard. The output is valid JSON consumable by any JSON parser.

Common Use Cases

Technical Details

js-yaml implements YAML 1.2 with optional support for YAML 1.1 quirks (the 'no'-as-false issue, octal numbers without 0o prefix). The parser produces a JavaScript object tree using native types: numbers, strings, booleans, null, arrays, and plain objects.

JSON.stringify serializes the object tree to JSON. Optional indentation produces pretty-printed output; without it the result is compact single-line JSON. Special values (NaN, Infinity, undefined) are not valid JSON; the converter coerces them to null where present.

Edge cases: YAML timestamps become ISO-8601 strings in JSON. YAML binary data (base64-encoded) becomes a string. Anchors and aliases are resolved into duplicate values in JSON, since JSON has no reference syntax.

Best Practices

Frequently Asked Questions

Are YAML comments preserved?
No. JSON has no comment syntax, so comments in the source YAML are dropped during conversion. Keep the YAML source if comments are part of your documentation.
Are YAML anchors and aliases resolved?
Yes. References (&anchor and *alias) are expanded into the referent value, producing duplicated content in the JSON output. JSON has no equivalent reference mechanism.
What about YAML's loose typing?
Loose strings are typed during YAML parsing: numeric-looking values become numbers, booleans become booleans, dates become ISO strings. To force string interpretation, quote the value in YAML.
Are tags supported?
Standard YAML tags (!!str, !!int, !!float, !!bool, !!null, !!seq, !!map) are honored. Custom tags are stripped to their underlying value.
Will my YAML round-trip cleanly?
Structurally yes if you re-emit the JSON back to YAML. Comments and anchor structure are lost; raw values are preserved.
Is my data uploaded to a server?
No. js-yaml runs in your browser.
What is the maximum size?
Up to 50 MB. js-yaml handles typical configuration files instantly; very large YAML may take noticeable time to parse.
Does it support multi-document YAML?
YAML supports multiple documents in one file separated by ---. The converter processes the first document by default; for multi-document handling, split the YAML first.