{ }
中文

JSON ↔ YAML Converter

Convert configuration between JSON and YAML, instantly and offline. Preserves anchors, references, and unicode characters.

Indent:

JSON, YAML, and when to use which

JSON and YAML solve overlapping problems — both describe structured data — but they have different cultural homes. JSON dominates wire formats and APIs because it is unambiguous, fast to parse, and supported by every language standard library. YAML dominates configuration files (Kubernetes manifests, CI pipelines, Ansible playbooks) because it is more compact, supports comments, and reads more like prose.

Every JSON document is a valid YAML document — YAML is a strict superset. Converting from JSON to YAML almost always produces a usable result. Converting from YAML to JSON occasionally loses information: comments are dropped, tags are normalised, and node-anchor references are flattened. This tool uses js-yaml, the most widely deployed YAML 1.2 parser for JavaScript, and runs entirely inside your browser tab.

Use cases

  • Translate a Kubernetes ConfigMap from YAML to JSON to feed it through jq.
  • Convert a JSON OpenAPI spec to YAML for human-friendly review.
  • Quickly reformat a CI pipeline definition copied from someone else's repository.
  • Validate that a YAML file parses without ambiguity before committing.
  • Convert a JSON snippet to YAML when writing GitHub Actions or Helm values.

Best practices

  • Avoid YAML's optional flow style for human-edited configs — block style scales better.
  • Always quote strings that look like numbers, booleans, or dates (YAML's "Norway problem").
  • Pick a single indentation level (two spaces is conventional) and enforce it via a linter.
  • When precision matters, prefer JSON — YAML 1.1 historically interpreted on/off/yes/no as booleans.

Frequently asked questions

Are comments preserved when going from YAML to JSON?
No. JSON has no comment syntax, so YAML comments are discarded during conversion.
What YAML version is supported?
YAML 1.2 via js-yaml. The notorious YAML 1.1 boolean coercions (yes/no/on/off) are not applied.
Does the tool handle multi-document YAML files?
It parses the first document. Multi-document streams (separated by ---) require an explicit toggle which is on the roadmap.
Why does my number get quoted in YAML output?
If the value would be parsed back as a different type (for example a string that looks like a number), js-yaml quotes it to preserve round-trip equality.