JSON to YAML Converter
Paste JSON and instantly get clean, readable YAML output with configurable indentation
Paste JSON on one side, get valid YAML on the other — no fiddling with indentation or brackets by hand. Handles nested objects, arrays, and mixed types correctly, with options for 2- or 4-space indent and flow-level control. And everything runs in your browser. Nothing gets uploaded.
How It Works
The converter parses your JSON into a JavaScript object using the browser's native JSON.parse(), then serializes it to YAML with the js-yaml library. Conversion starts automatically as you type — there's a short debounce delay so it doesn't thrash on every keystroke. The result is valid YAML that any parser will accept.
Examples
Simple API Response
Turning a REST endpoint response into a YAML fixture for tests.
{
"id": 42,
"name": "Acme Corp",
"active": true,
"tags": ["premium", "enterprise"]
}
id: 42
name: Acme Corp
active: true
tags:
- premium
- enterprise
Docker Compose Service Config
You exported a service definition as JSON from a tool and need it in docker-compose.yml format.
{
"services": {
"web": {
"image": "nginx:alpine",
"ports": ["80:80", "443:443"],
"environment": {
"NODE_ENV": "production"
}
}
}
}
services:
web:
image: nginx:alpine
ports:
- "80:80"
- "443:443"
environment:
NODE_ENV: production
GitHub Actions Workflow Snippet
Building a CI pipeline from a JSON template your team shares internally.
{
"name": "CI",
"on": ["push", "pull_request"],
"jobs": {
"test": {
"runs-on": "ubuntu-latest",
"steps": [
{"uses": "actions/checkout@v4"},
{"run": "npm test"}
]
}
}
}
name: CI
"on":
- push
- pull_request
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm test
Who Uses This
Converting JSON outputs from APIs into Kubernetes manifests, Helm charts, and Ansible playbooks.
Turning exported JSON configs into YAML for Docker Compose and CI/CD pipeline files.
Learning how JSON structures map to YAML indentation — side-by-side comparison makes it click.
Reformatting pipeline configuration exports before committing them to version control.
Common Mistakes
JSON doesn't allow trailing commas after the last item in an object or array. Your editor might not flag it, but this converter will. Remove the extra comma before the closing } or ].
JSON requires double quotes for all keys and string values. Single quotes are a JavaScript thing — they won't parse as valid JSON. Swap them out before converting.
If you convert JSON to YAML, add comments, then swap back to JSON — those comments vanish. JSON has no comment syntax. Save your commented YAML separately before round-tripping.
Technical Details
- Processing: 100% client-side — nothing is uploaded
- Library: js-yaml (widely used, spec-compliant)
- Input Limit: No hard cap, but very large files (10MB+) may slow down your browser
- Browser Support: Chrome, Firefox, Safari, Edge
- Output: YAML 1.2 compatible
Frequently Asked Questions
What is YAML and why do people prefer it over JSON for config files?
YAML stands for "YAML Ain't Markup Language." It uses indentation instead of brackets, which makes config files much easier to scan. You can also add comments with # — something JSON flat-out doesn't support. That alone is reason enough for most teams to pick YAML for Docker Compose, Kubernetes, and CI pipelines.
Can I convert YAML back to JSON?
Yes. Hit the Swap button in the toolbar and it reverses direction. You can also use our YAML to JSON Converter directly. One thing to know: any YAML comments or anchors will be lost, since JSON has no way to represent them.
Is my data safe when I paste it here?
Your JSON never leaves your browser. The conversion happens entirely in JavaScript on your device — no server calls, no uploads, no analytics on your input. Close the tab and the data is gone.
Why does my JSON fail to convert?
Nine times out of ten it's a syntax issue: trailing commas, single quotes instead of double quotes, or unescaped special characters. Try running your JSON through a validator first. The error message in the output panel usually points to the exact line.
What's the difference between 2-space and 4-space YAML indentation?
Functionally, nothing — YAML parsers accept both. Two spaces is the convention for Kubernetes and most DevOps tooling. Four spaces is more common in Python-adjacent projects. Pick whichever your team already uses and stay consistent.