How to Convert JSON to YAML: Complete Guide
Last updated: 2026-04-14
JSON is great for machines, but YAML is what humans prefer to read and edit. Kubernetes definitions, Docker Compose files, Helm charts, and Ansible playbooks are all written in YAML — and for good reason. Indentation-based structure, comment support, and multi-line string handling make YAML far more ergonomic for configuration that people maintain by hand. When you have JSON data that needs to live in a YAML-based workflow, conversion is the bridge.
Step-by-Step: Convert JSON to YAML with Convertee
- Open Convertee, set source to JSON and target to YAML.
- Paste your JSON into the input panel, or drag-and-drop a
.jsonfile. - Adjust YAML output options: indent width, flow vs. block style, and line width for folding.
- Click Convert (Cmd+Enter).
- Copy the YAML output or download it as a
.yamlfile.
Everything runs locally in your browser. Your JSON data is never transmitted to a remote server.
Understanding the Formats
JSON
JSON (RFC 8259) is strict and unambiguous: curly braces for objects, square brackets for arrays, double quotes for keys and string values. No comments, no trailing commas. This rigidity is an advantage for machines but a friction point for humans editing configuration files.
YAML
YAML (YAML 1.2) replaces braces with indentation, drops mandatory quoting for most strings, and adds features like comments, anchors, and multi-line block scalars. Since YAML is a superset of JSON, every JSON file is already valid YAML — but the point of converting is to get the human-friendly formatting.
Before / After Example
Input JSON:
{
"name": "my-app",
"version": "1.0.0",
"dependencies": {
"express": "^4.18.0",
"dotenv": "^16.0.0"
},
"scripts": {
"start": "node index.js",
"test": "jest --coverage"
}
}Output YAML:
name: my-app
version: 1.0.0
dependencies:
express: ^4.18.0
dotenv: ^16.0.0
scripts:
start: node index.js
test: jest --coverageCommon Use Cases
- Kubernetes manifest authoring. You prototype a deployment spec as a JSON object in code, then convert it to YAML for
kubectl apply. - Helm chart values. Helm values files are YAML. If your CI pipeline generates values as JSON, converting to YAML produces a file that
helm install -faccepts directly. - Docker Compose from API output. You fetch service configuration from a REST endpoint as JSON and need a docker-compose.yml to spin up the stack locally.
- Readable configuration sharing. YAML's comment support and clean formatting make it better suited for config files that multiple team members edit. Converting JSON to YAML before checking it into a repo makes code reviews easier.
Options and Configuration
| Option | Default | What It Does |
|---|---|---|
| Indent width | 2 spaces | Number of spaces per indentation level. YAML convention is 2, but some projects use 4. |
| Style | Block | Block style uses indentation (standard YAML). Flow style uses braces and brackets (JSON-like, compact). |
| Line width | 80 | Maximum line width before long strings are folded onto multiple lines. |
| Quote strings | Only when needed | Forces all string values to be quoted. Useful when values could be misinterpreted as booleans or numbers (e.g., yes, 3.14). |
Frequently Asked Questions
- Will Convertee add comments to the YAML output?
- Automatic comment generation is not supported, since JSON has no comment equivalent. The output is clean YAML that you can annotate manually afterward.
- How does Convertee handle ambiguous YAML values like 'yes' or 'no'?
- String values that YAML might interpret as booleans (yes, no, true, false, on, off) are automatically quoted in the output to preserve their original string type.
- Can I choose between block and flow style?
- Yes. Block style (the default) uses indentation for structure. Flow style uses braces and brackets, similar to JSON but without mandatory quoting.
- Does this work with deeply nested JSON?
- Yes. Convertee handles arbitrary nesting depth. Each level of nesting maps to one additional level of indentation in the YAML output.