Skip to content
OpsAtlas

YAML ⇄ JSON converter

Kubernetes

Paste YAML or JSON and convert it in either direction. Errors point to the exact line, and values that other YAML parsers would read differently are flagged.

Runs entirely in your browser — your input is never uploaded.

JSON output

Paste YAML or load the sample. Conversion happens in your browser.

How the conversion works

YAML → JSON parses the input with a YAML 1.2 parser. It expands anchors (&name), aliases (*name) and merge keys (<<), rejects duplicate keys, and prints the resulting data as JSON. Several documents separated by --- become a JSON array.

JSON → YAML parses the JSON and writes block-style YAML with 2-space indentation, the convention used by Kubernetes and Docker Compose. Strings that would change type when unquoted, such as "yes", "0042" or "22:22", are quoted automatically.

Every JSON document is also valid YAML 1.2. Converting JSON to YAML is purely about readability: comments become possible and there is less punctuation.

Example: the values that bite

countries: [GB, NO, SE]
enabled: yes
version: 1.10
port_map: 22:22
mode: 0755

Different parsers read these differently:

ValueYAML 1.2 (this tool, Go yaml.v3)YAML 1.1 (PyYAML, Ruby Psych)
NO"NO"false
yes"yes"true
1.101.11.1
22:22"22:22"1342 (base 60)
0755755493 (octal)

The converter flags each of these with its line number. The fix is the same every time: quote the value.

Converting on the command line

If you have yq or python3:

yq -o=json '.' config.yaml                 # YAML → JSON
yq -p=json -o=yaml '.' config.json         # JSON → YAML
python3 -c 'import sys, yaml, json; print(json.dumps(yaml.safe_load(sys.stdin), indent=2))' < config.yaml

The Python one-liner uses PyYAML, a YAML 1.1 parser, so it will turn NO into false. That makes it a handy way to see the problem in practice.

Common errors

  • “Map keys must be unique”: the same key appears twice in one mapping. Most YAML parsers silently keep the last one, which hides real bugs. The converter refuses it.
  • Tabs for indentation: YAML forbids tab characters for indentation. Replace them with spaces.
  • Trailing commas and single quotes in JSON: both are invalid in JSON (though valid in JavaScript). The error message points at the exact character.

Frequently asked questions

Which YAML version does the converter follow?
YAML 1.2 (core schema), the current specification. It also expands YAML 1.1 merge keys (<<) because Kubernetes, Compose and CI files use them, and warns about every value that a YAML 1.1 parser such as PyYAML would read differently.
What is the Norway problem?
In YAML 1.1, the unquoted country code NO (like yes, no, on, off, y and n) is a boolean, so a list of countries turns Norway into false. YAML 1.2 keeps it as a string, but many tools still use 1.1 rules. Quote such values to be safe.
Why did my version number 1.10 become 1.1?
Unquoted, 1.10 is a floating-point number and the trailing zero is lost. Quote versions, ZIP codes, IDs with leading zeros and anything else that only looks numeric.
What happens to comments, anchors and multiple documents?
JSON has no comments, so they are dropped. Anchors and aliases are expanded into full copies. Several documents separated by --- become a JSON array.
Is my data uploaded anywhere?
No. Parsing and conversion run in your browser. Small inputs are stored compressed in the page URL so you can share a result; clear the input to remove them.
  • Kubernetes YAML validator and visualizer

    Paste Kubernetes manifests to get a resource diagram and a security and best-practice review: privileged pods, root, probes, limits, deprecated APIs.

    KubernetesBeta
  • docker run to Docker Compose converter

    Convert docker run commands into a clean compose.yaml: ports, volumes, env, networks, healthchecks and limits. Runs in your browser.

    Docker
  • GitHub Actions matrix expander

    Preview every job a GitHub Actions strategy.matrix creates, with include and exclude applied exactly as GitHub does, before you push.

    CI/CD
  • Kubernetes manifest generator

    Generate a Kubernetes Deployment and Service with resources, probes and a hardened securityContext, plus optional Ingress and HPA.

    Kubernetes

Last updated · More Kubernetes tools