Home/ Glossary/ JSON ↔ YAML
Konverter

JSON ↔ YAML

The JSON ↔ YAML Converter translates between JSON and YAML in both directions. YAML is the de facto format for Kubernetes manifests, Docker Compose files, GitHub Actions, Ansible playbooks, and many other DevOps tools, while JSON is the standard for REST APIs and web data. This converter is the fastest path between the two worlds – paste in either format and get the other in seconds.

What is YAML?

YAML (YAML Ain't Markup Language) is a human-friendly data serialization format. It uses indentation instead of braces and brackets to express structure, making it much more readable than JSON for configuration files. YAML supports all the same data types as JSON (strings, numbers, booleans, null, arrays, and objects) plus additional types like multi-line strings, ordered maps, and custom tags. Comments are supported with the # character. YAML is a superset of JSON: any valid JSON document is also valid YAML. However, YAML's flexibility and reliance on significant whitespace make it error-prone when edited manually.

How does the converter work?

For JSON-to-YAML, the tool parses the JSON into an object tree and serializes it as YAML using 2-space indentation. JSON arrays become YAML sequences with the - prefix. JSON objects become YAML mappings. Strings that look like special YAML values (true, null, 1.5) are quoted to prevent type misinterpretation. For YAML-to-JSON, the tool parses the YAML using a spec-compliant parser that handles aliases, anchors, and multi-line scalars, then serializes the result as indented JSON. YAML anchors (&) and aliases (*) are resolved and inlined in the JSON output.

Typical Use Cases

  • Converting a JSON API response to YAML for use in a Kubernetes ConfigMap or Helm chart
  • Translating a YAML CI/CD pipeline config to JSON for programmatic processing
  • Generating YAML fixtures from JSON test data for frameworks that require YAML
  • Checking how a YAML config will be interpreted as a data structure by converting to JSON

Step-by-step Guide

  1. Step 1: Paste your JSON or YAML into the input field.
  2. Step 2: Select the conversion direction: JSON → YAML or YAML → JSON.
  3. Step 3: The output appears instantly with correct indentation and formatting.
  4. Step 4: Copy or download the result to use in your project.

Example

Input
{"apiVersion":"v1","kind":"Service","metadata":{"name":"my-svc"}}
Output
apiVersion: v1
kind: Service
metadata:
  name: my-svc

Tips & Notes

  • YAML is sensitive to indentation – always use spaces, never tabs, to avoid parsing errors.
  • Special string values like 'true', 'false', 'null', 'yes', and 'no' must be quoted in YAML to prevent automatic type coercion.
  • Use the YAML Formatter (yaml-format) to validate and pretty-print YAML without converting it.

Frequently Asked Questions

Is YAML a superset of JSON?
Yes. YAML 1.2 is a strict superset of JSON, meaning any valid JSON document is also valid YAML. However, YAML adds many features (comments, anchors, multi-line strings) that have no JSON equivalent.
What happens to YAML anchors and aliases during conversion?
Anchors (&name) and aliases (*name) are resolved during YAML parsing and the referenced values are inlined in the JSON output. JSON has no concept of references or aliases.
Why does YAML sometimes misinterpret my strings as booleans?
YAML 1.1 (used by many older parsers) treats values like 'yes', 'no', 'on', 'off' as booleans. YAML 1.2 restricts this to only 'true' and 'false'. Quote your strings to be safe.
JSON ↔ YAML
Convert JSON to YAML and YAML to JSON — live, bidirectional, and with syntax validation.
Open Tool