Skip to content

JSON to YAML

Convert JSON to YAML format online instantly. Free JSON to YAML converter for configuration files with clean indented output.

YAML to JSON
YAML output will appear here...

About JSON to YAML Converter

Convert JSON data to YAML format. YAML is often used for configuration files as it's more human-readable than JSON. Supports nested objects, arrays, and special characters.

How to Use JSON to YAML

1

Paste your JSON

Paste your JSON data into the input editor. Drag-and-drop a .json file or click Upload to load from disk.

2

View YAML output

The converted YAML appears instantly with proper indentation, unquoted keys, and clean structure. Each level of JSON nesting becomes one level of YAML indentation.

3

Customize indentation

Choose 2-space (most common, GitHub Actions/K8s standard), 4-space (older style), or other indent widths. The output is valid YAML at any indentation.

4

Copy or download

Click Copy to use the YAML elsewhere, or Download as a .yaml file. Add comments manually after conversion (YAML supports # comments which JSON does not).

When to Use JSON to YAML

Migrating JSON configs to YAML for readability

Long JSON configs become hard to read with deep nesting and many quotes. Converting to YAML produces shorter, more scannable output — ideal for configs reviewed by humans rather than processed by APIs. Common in DevOps migrations from custom JSON formats to standard YAML tools.

Generating Kubernetes manifests from JSON sources

If your application generates Kubernetes resources programmatically (in JSON format), convert to YAML before applying with kubectl. Kubernetes accepts both, but YAML manifests are convention in K8s tooling, examples, and documentation — converting fits your generated configs into the ecosystem.

Creating Helm chart values.yaml files

Helm charts are configured via values.yaml. If you're migrating from Helm 2 (which sometimes used JSON values) or from a JSON-driven config system to Helm, convert your values to YAML format. The output uses Helm-friendly conventions (lowercase booleans, unquoted keys).

Transforming API responses for human review

When inspecting JSON API responses (database dumps, audit logs, debug output), converting to YAML makes them dramatically easier to read. Especially valuable for deeply nested responses where JSON's brackets and commas create visual clutter.

JSON to YAML Examples

Simple conversion

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

Basic JSON object becomes 3 lines of YAML. Keys lose their quotes (YAML doesn't require them for simple keys), values are preserved exactly. The output is roughly 25% shorter than the JSON input.

Nested object

Input
{"server":{"host":"localhost","port":8080,"ssl":true}}
Output
server:
  host: localhost
  port: 8080
  ssl: true

Nested JSON object becomes nested YAML mapping with 2-space indentation. Each level of JSON nesting maps to one level of indentation. Result is more readable than the JSON, especially for configs with multiple levels of structure.

Array of objects

Input
[{"name":"Alice","role":"admin"},{"name":"Bob","role":"user"}]
Output
- name: Alice
  role: admin
- name: Bob
  role: user

JSON arrays become YAML sequences with each item prefixed by '- '. Array of objects produces a list where each item is a YAML mapping. Common pattern in YAML configs (Kubernetes resources, CI matrix builds, RBAC rules).

Tips & Best Practices for JSON to YAML

  • 1.Add comments after conversion. YAML supports # comments which JSON does not. Use them to document non-obvious values, mark sections, or warn about specific behaviors. JSON-to-YAML is a one-way upgrade in this regard.
  • 2.Use 2-space indentation for production YAML (Kubernetes, GitHub Actions, Docker Compose all default to this). 4-space is acceptable but unusual in modern YAML codebases.
  • 3.Watch for type ambiguity. YAML treats unquoted 'yes', 'no', 'on', 'off' as booleans (in YAML 1.1) — quote them if you mean string. The converter handles this automatically but be aware when hand-editing the output.
  • 4.Multi-line strings: use YAML's | (literal) or > (folded) block scalar syntax for long strings instead of escaped \n. Convert to YAML, then manually reformat long strings for better readability.
  • 5.If you're using YAML for Kubernetes specifically, validate with kubectl --dry-run=client after conversion. Some K8s resources have specific structural requirements that converters might not check.
  • 6.For round-trip-safe conversion (YAML → JSON → YAML producing identical output), be aware of subtle differences: key order may change in some converters, number representations might normalize (1.0 → 1), and comments are lost permanently.

Frequently Asked Questions

YAML is more human-readable than JSON for configuration files — no brackets, no quotes around keys, support for comments, more compact for hierarchical data. Converting JSON to YAML is common when migrating configs from JSON-based systems to YAML-based ones (e.g., GitHub Actions, Kubernetes, Helm charts, Ansible playbooks).