Skip to content
codinganthem
All tools/Converters/YAML to JSON

YAML to JSON

Convert YAML to JSON online, free and instant. Handles nested objects, arrays, block text, anchors and merge keys, with line-numbered errors for docker-compose and Kubernetes files.

JSON → YAML
More
Buy me a coffee

How to convert YAML to JSON online

Paste YAML, such as a docker-compose file, a GitHub Actions workflow or a Kubernetes manifest, and the JSON appears with 2-space indentation, ready to copy or download. If the YAML is invalid, the error gives the line and column.

# YAML
name: CodingAnthem
tools:
  - JSON Formatter
  - Base64

# JSON
{
  "name": "CodingAnthem",
  "tools": ["JSON Formatter", "Base64"]
}

How YAML values become JSON

  • The converter follows YAML 1.2, so yes, no, on and off stay strings; only true and false become booleans. Older YAML 1.1 tools treat them as booleans.
  • ~ and null become null. Numbers become numbers: 0755 is 755, while 0o755 is octal, 493. Quote values like "007" to keep them as text.
  • Dates such as 2026-11-27 stay strings, since JSON has no date type.
  • .inf and .nan have no JSON equivalent and come out as null.
  • Block text with | keeps line breaks; > folds lines into one.
  • Anchors and aliases (&name, *name) are expanded into full copies.
  • Merge keys (<<: *defaults), common in docker-compose and CI files, copy the anchored keys into the mapping. Keys written in the mapping itself win, and <<: [*a, *b] merges several.

Common YAML errors

  • Tabs: YAML indentation must use spaces. "Tabs are not allowed as indentation" means a tab was found.
  • Inconsistent indentation, such as a key indented under a value on the same line, gives "Nested mappings are not allowed in compact mappings".
  • Duplicate keys in the same mapping are an error rather than being silently overwritten.
  • Files with several documents separated by --- aren't supported. Convert one document at a time.

To go the other way, use JSON to YAML. To check or tidy the result, use the JSON Formatter.

Frequently asked questions

How do I convert YAML to JSON?+

Paste the YAML into the input. The JSON appears instantly, and you can copy it or download it as a .json file.

Why did yes become a string instead of true?+

The converter follows YAML 1.2, where only true and false are booleans. Write true or false if you need a boolean.

Does it support anchors, aliases and merge keys?+

Yes. Aliases are expanded into full copies, and merge keys (<<: *defaults) copy the anchored keys in, with keys written locally taking priority.

Can I convert a file with several documents?+

No. A file with --- separators gives an error; paste one document at a time.

Is my YAML uploaded?+

No. Conversion runs in your browser, so configs and secrets in them stay on your device.