YAML ↔ JSON Converter

Convert YAML to JSON and JSON to YAML instantly. Perfect for Kubernetes configs, Docker Compose files, CI/CD pipelines, and API development. No external dependencies.

What is YAML ↔ JSON Converter?

A YAML ↔ JSON Converter transforms data between YAML (YAML Ain't Markup Language) and JSON, two complementary formats that dominate modern software configuration and data exchange. YAML is a human-friendly data serialization format designed for configuration files, prioritizing readability with its indentation-based hierarchy, optional quotes, and support for comments—making it the standard format for Kubernetes manifests, Docker Compose files, GitHub Actions workflows, Ansible playbooks, Helm charts, CircleCI configs, and virtually all DevOps infrastructure-as-code tooling. JSON is the universal format for REST APIs, web services, NoSQL databases, and programmatic data exchange—compact, strict, and parseable by every programming language without external libraries. The need to convert between them is constant in modern development: converting a Kubernetes YAML manifest to JSON for a Kubernetes API call, transforming a JSON API response into YAML to create a reusable config template, converting GitHub Actions workflow JSON exports back to YAML for editing, or translating between YAML configuration and JSON schema definitions. This converter handles both directions instantly, including nested structures, arrays, multi-line strings, and boolean/null type coercion.

How to Use YAML ↔ JSON Converter

Select the conversion direction using the tabs or toggle at the top: YAML → JSON or JSON → YAML. Paste your source data into the input area, or click a preset sample button to load example Kubernetes, Docker Compose, or GitHub Actions YAML. Click Convert to produce the output in the right panel. The swap button (⇄) flips the conversion—using the current output as the new input with the direction reversed, useful for round-trip verification. For YAML → JSON: comments are stripped (JSON does not support comments), indentation-based hierarchy becomes nested JSON objects, YAML booleans (true/false, yes/no, on/off) become JSON booleans, and YAML multi-line strings collapse appropriately. For JSON → YAML: JSON objects become indented YAML mappings, arrays become YAML sequences with dash (−) prefixes, strings are quoted only when necessary, and a configurable indentation size (2 or 4 spaces) is applied. Copy the output with the copy button or download it as a .yaml or .json file.

FAQ

Does this handle nested YAML structures and arrays?

Yes. The converter handles arbitrarily nested objects (YAML mappings → JSON objects), sequences (YAML lists with - prefixes → JSON arrays), inline flow syntax (JSON-like syntax within YAML such as [1, 2, 3] or {key: value}), multi-line string blocks (literal | and folded > blocks), and mixed scalar types (strings, integers, floats, booleans, nulls). Complex nested Kubernetes specs with multiple levels of nesting are converted correctly.

Can I convert Kubernetes manifests between YAML and JSON?

Yes. Kubernetes natively supports both YAML and JSON for all its resource manifests (Pods, Deployments, Services, ConfigMaps, etc.). The kubectl command accepts both formats. Use this converter to convert a YAML manifest to JSON for use with the Kubernetes REST API directly, or to convert a JSON response from kubectl get -o json back to a YAML template. The converter correctly handles Kubernetes-specific constructs like multi-document YAML files (separated by ---), nested spec/status structures, and label selectors.

What happens to YAML comments during conversion to JSON?

YAML supports comments (lines beginning with #) but JSON does not. Comments are stripped completely during YAML → JSON conversion. If your YAML config relies heavily on comments for documentation (a common practice in Kubernetes and Docker Compose files), consider maintaining the YAML source as the canonical version and only converting to JSON when making API calls or for systems that require JSON format.

Are YAML anchors and aliases supported?

Basic YAML anchors (&anchorName) and aliases (*anchorName) for value reuse are supported by the converter—the referenced values are expanded into their full representations in the output. The merge key (<<: *anchor) used for object merging in Docker Compose and some Kubernetes tools may have limited support depending on the parser. For complex multi-document YAML with extensive anchor usage (common in Helm charts), test your specific file and verify the output.

Why does my YAML number convert to a string in JSON?

YAML infers types based on value format. A value without quotes is typed automatically: 42 becomes an integer, 3.14 a float, true a boolean, null a null. If a value looks like a number but should be a string (e.g., a ZIP code '01234' that loses its leading zero), you must quote it in YAML: '01234'. During JSON → YAML conversion, JSON string values that look like numbers are kept as quoted strings to preserve their type. If type coercion is causing issues, check that your YAML source quotes string values that resemble other types.