Calcoid
Tech

YAML to JSON Converter

Convert YAML to JSON or JSON back to YAML in your browser. Block-style YAML 1.2 subset with literal and folded multiline scalars, scalar typing, and 2 or 4 space indent. Self-contained, no library required.

Convert between YAML and JSON
Direction
Output indent

0 of 100,000 characters.

Frequently Asked Questions about the YAML to JSON Converter

Which YAML version does this converter follow?
The parser targets the YAML 1.2 spec published in 2009, which is the version most modern tools (kubectl, Docker Compose, GitHub Actions, Ansible) read by default. The legacy YAML 1.1 quirks that 1.2 fixed are not honored here: yes, no, on, and off stay as strings rather than becoming booleans, and 0o755 stays a string rather than an octal number. If you paste YAML that relied on those 1.1 behaviors, the converter treats those tokens as plain strings, which is the safer choice and matches how every 1.2-compliant parser reads the same input.
Why is YAML indentation-sensitive and what counts as an indent?
Block-style YAML uses leading spaces, and only spaces, to express nesting. The number of spaces is not fixed by the spec: a child must simply be indented more than its parent, and siblings must share the exact same column. The converter follows this rule and rejects tab characters in indentation up front, because tabs and spaces mix unpredictably depending on editor settings. The output indent setting (2 or 4 spaces) controls only the JSON or YAML the tool writes back; the input you paste can use any consistent space count, as long as it is consistent.
Which YAML features does this converter support?
Block-style mappings (key: value), block-style sequences (- item), nested objects via indentation, strings (plain, single-quoted, double-quoted with escape sequences), numbers (integers and decimals with optional sign), booleans (true and false in any common casing), null (null, ~, or empty), comments (# stripped before parsing), the optional --- document start marker, and literal (|) and folded (>) block scalars for multiline strings. Not supported: flow style ([1, 2] or {a: 1}), anchors and aliases (&id, *id), tags (!!str), directives (%YAML), multi-document streams beyond the first, and complex keys. Anything outside the supported subset either fails parsing with a clear error or, for flow style, is treated as a plain string.
Is every valid YAML 1.2 file also valid JSON?
No, the relationship runs the other way. Every valid JSON document is also valid YAML 1.2, because the YAML 1.2 spec was deliberately rewritten in 2009 to make JSON a strict subset. That is why you can paste raw JSON into a YAML parser and have it work. The reverse is not true: YAML supports comments, multiline scalars, anchors, custom tags, and unquoted strings, none of which JSON allows. This converter handles that one-way mismatch by stripping comments, expanding | and > block scalars into JSON strings, and serializing every YAML value to its JSON equivalent.
How are multiline strings (| and >) parsed?
A pipe (|) is the literal block scalar: every newline in the indented block is preserved, so a YAML key with a five-line value comes out as a JSON string containing four newline characters. A greater-than sign (>) is the folded block scalar: runs of non-empty lines fold into a single space, and a blank line becomes a newline boundary, which is the right shape for prose that wraps in the source for readability. Both forms use the same indentation rule as the rest of YAML: the body is whatever lines are indented further than the key carrying the marker, and the first such line sets the column for the whole block. Trailing blank lines are clipped by default, which matches the YAML 1.2 default chomping mode.