Home/ Glossary/ YAML ↔ JSON
Konverter

YAML ↔ JSON

The YAML to JSON Converter translates YAML documents to JSON and JSON back to YAML. It is the mirror of json-yaml with a YAML-first workflow – ideal for developers who start with a Kubernetes manifest, Helm chart, or Ansible playbook and need to convert it to JSON for programmatic processing, schema validation, or API submission.

Why convert YAML to JSON?

YAML is a popular configuration format but has limited tooling support compared to JSON. JSON Schema validators, most REST APIs, NoSQL databases, and data processing tools natively accept JSON but not YAML. Converting YAML to JSON allows you to use jq for querying, JSON Schema for validation, or send configuration data to APIs without adding a YAML parser dependency. JSON is also unambiguous – YAML's flexible type coercion (where 'yes' becomes boolean true) can cause surprises that are easier to diagnose after seeing the parsed JSON output.

How does the converter work?

For YAML-to-JSON, the tool uses a spec-compliant YAML 1.2 parser that correctly handles anchors (&), aliases (*), multi-line scalars (| and >), and all YAML data types. Anchors and aliases are resolved and inlined in the JSON output. YAML datetimes are serialized as ISO 8601 strings. YAML null (~ or the word null) becomes JSON null. YAML comments are dropped since JSON has no comment syntax. For JSON-to-YAML, the tool serializes the JSON object tree with 2-space indentation and YAML block style for objects and arrays.

Typical Use Cases

  • Converting a Kubernetes YAML manifest to JSON for processing with kubectl or Terraform tooling
  • Validating a Helm values.yaml file against a JSON Schema
  • Passing YAML-sourced configuration to a REST API endpoint that only accepts JSON
  • Diagnosing YAML type coercion issues by inspecting the parsed JSON output

Step-by-step Guide

  1. Step 1: Paste your YAML or JSON into the input field.
  2. Step 2: Select the conversion direction: YAML → JSON or JSON → YAML.
  3. Step 3: The output appears instantly with proper formatting.
  4. Step 4: Copy or download the converted result.

Example

Input
name: Alice
age: 30
active: true
Output
{
  "name": "Alice",
  "age": 30,
  "active": true
}

Tips & Notes

  • YAML 1.1 parsers treat 'yes'/'no'/'on'/'off' as booleans; YAML 1.2 does not. Convert to JSON to verify how your parser actually interprets these values.
  • Multi-document YAML files (separated by ---) are not valid JSON; the tool converts only the first document by default.
  • Use the YAML Formatter (yaml-format) to lint and pretty-print YAML without converting it.

Frequently Asked Questions

What happens to YAML anchors during conversion?
Anchors (&name) and aliases (*name) are resolved by the YAML parser before conversion. The referenced value is inlined at each alias location in the JSON output. JSON has no equivalent reference mechanism.
Can I convert a multi-document YAML file?
Standard JSON can only represent a single document. The tool converts the first YAML document (before the first ---) and warns if additional documents are present.
Is YAML a superset of JSON?
Yes. YAML 1.2 is a strict superset of JSON, so any valid JSON is also valid YAML. The reverse is not true – YAML has many features (comments, anchors, multi-line strings) not present in JSON.
YAML ↔ JSON
Convert YAML to JSON and JSON to YAML — live, bidirectional, and with syntax validation.
Open Tool