YAML to JSON Converter

Convert YAML to JSON instantly with correct nesting and array handling. Paste a YAML file, get valid JSON for APIs, scripts or config loaders. Nothing is uploaded.

Loading tool…

Worked examples

  • A small config mapping

    The everyday case: a flat YAML mapping becomes a flat JSON object, which is what most config loaders and APIs expect.

  • Nested mapping with a block sequence

    Shows how YAML indentation becomes nested objects and a dash list becomes a JSON array — the two structures people check when converting Kubernetes or Docker Compose files.

  • Quoted strings and an empty value

    Confirms that quoting is respected: a colon inside a string and a numeric-looking string both stay as plain text instead of being reinterpreted.

What this converter does

YAML and JSON describe the same kinds of data — objects, arrays, strings, numbers, booleans and null — with different syntax. YAML relies on indentation and a handful of punctuation rules; JSON relies on braces, brackets and quotes. This tool parses your YAML and writes it back out as JSON, so the meaning stays identical and only the formatting changes. The result is plain, standard JSON.

When you need it

  • Reading a Kubernetes manifest, Docker Compose file, GitHub Actions workflow or CI config as JSON so you can process it with JSON.parse in a script.
  • Feeding YAML-based config into a system or API that only accepts JSON.
  • Comparing a YAML file against a JSON schema, since most schema validators expect JSON structures.

Rules the converter applies

  1. Indentation becomes nesting. Each indented YAML block becomes a nested JSON object.
  2. Dash lists become arrays. A - item sequence becomes a JSON array in the same order.
  3. Quoting is respected exactly. If a YAML value is quoted (version: "1.0"), it stays a JSON string; if it's bare (version: 1.0), it becomes a JSON number.
  4. Comments are dropped. JSON has no comment syntax, so anything after # in the YAML is discarded — there is no way to carry it through.
  5. Invalid YAML stops the conversion and shows the parser's error instead of guessing at a result.

YAML and JSON side by side

| YAML | JSON | Note | |---|---|---| | a: 1 | {"a": 1} | Mapping becomes an object | | - 1
- 2 | [1, 2] | Dash list becomes an array | | yes (bare) | "yes" | YAML 1.2 only treats true and false as booleans, so yes, no, on and off stay strings; a YAML 1.1 parser such as PyYAML would give booleans | | null or ~ | null | Both YAML spellings map to the same JSON value | | key: (no value) | {"key": null} | An empty value in YAML is explicit null in JSON |

This is the harder direction of the JSON/YAML pair: YAML is a superset of JSON in practice, so every JSON document is already valid YAML and converts losslessly, but converting YAML to JSON can lose information that JSON has no way to represent — comments, anchors and aliases, and multi-document separators (---) all disappear.

Things to check after converting

  • If your YAML used anchors (&name) and aliases (*name) to reuse a block, the JSON output will contain the expanded value at every reference point, not a link back to one definition — correct data, but a larger file.
  • Multi-document YAML files (more than one ----separated document) aren't supported; split the file first and convert each part.
  • If a key appears more than once at the same level, the conversion stops with a "Map keys must be unique" error and the line number, rather than silently keeping one of them.
  • The parser follows YAML 1.2. Dates such as 2024-01-15 stay strings, 0x1F and 0o17 become numbers, .inf and .nan become null (JSON has no way to write them), and merge keys (<<: *defaults) are expanded into the keys they pull in.

Limits

Input is capped at 2 MB, which covers any realistic single config file. Very large arrays or deeply nested structures may render slowly in the browser preview even though the conversion itself completes quickly.

Frequently asked questions

Is my YAML uploaded anywhere?
No. The conversion runs entirely in your browser; nothing is sent to a server.
What happens to YAML comments?
They are dropped. JSON has no comment syntax, so anything after a # is discarded during conversion.
Does it handle multi-document YAML files?
No — this tool expects a single YAML document. Split files that use --- separators before converting each part.
Why does my number become a string in the JSON output?
If the YAML value was quoted (like version: "1.0"), YAML treats it as a string, and the converter preserves that exactly.
Are anchors, aliases and merge keys handled?
Yes. Aliases are replaced by the value they point to and merge keys (<<: *defaults) are expanded, so the JSON contains the full data with no references.