← Home

YAML ↔ JSON

Contact us
YAML
JSON

What is YAML?

YAML ("YAML Ain't Markup Language") is a human-friendly data serialisation format commonly used for configuration files. It uses indentation and minimal punctuation to express nested structures, making it easier to read and write than JSON for complex configs.

YAML is a superset of JSON — every valid JSON document is also valid YAML, but YAML supports additional features like comments, multi-line strings, and anchors.

When to convert

  • Converting Kubernetes / Docker Compose configs to JSON for APIs
  • Transforming CI/CD pipeline definitions (GitHub Actions, CircleCI) for inspection
  • Migrating app configs between YAML-based and JSON-based tools
  • Debugging YAML by viewing the equivalent parsed JSON structure
  • Generating YAML config files from JSON API responses

Key differences

  • YAML uses indentation; JSON uses braces {} and brackets []
  • YAML supports comments (# like this); JSON does not
  • YAML strings rarely need quotes; JSON strings always require double quotes
  • YAML has anchors (&anchor) and aliases (*alias) for reuse; JSON has no equivalent
  • JSON is a strict subset — no tabs, trailing commas, or comments allowed

How this tool works

Conversion uses the yaml library, which is spec-compliant with YAML 1.2. YAML → JSON parses the YAML input and re-serialises it as pretty-printed JSON with 2-space indentation. JSON → YAML parses the JSON input and produces clean, readable YAML output.

Everything runs entirely in your browser — no data is sent to a server. Note: YAML-only features like comments and anchors are lost when converting to JSON, as JSON has no equivalent representation.