Convert JSON to YAML
Convert JSON data to YAML format instantly. Handles nested objects, arrays, and all JSON types. 100% client-side.
Paste your JSON, pick an indent size, and get valid YAML back — nested objects, arrays, nulls, all of it handled correctly. Strings only get quoted when YAML's spec actually demands it, so the output stays clean and readable. And everything runs in your browser. Nothing gets uploaded.
How It Works
The tool first validates your JSON to catch syntax errors — missing commas, trailing commas, unquoted keys, that sort of thing. Once the JSON parses cleanly, it walks the data tree recursively. Objects become YAML mappings with key: value pairs, arrays turn into dash-prefixed sequences, and primitives map directly to their YAML equivalents. Strings are left unquoted unless they contain characters that YAML would misinterpret (colons, hashes, brackets, etc.).
Examples
Simple API Response
A typical user object from a REST endpoint — the kind you'd drop into a config file.
{
"name": "Alice",
"age": 30,
"active": true
}
name: Alice
age: 30
active: true
Docker Compose Service Definition
Converting a JSON service config into something docker-compose.yml can actually use. Nested objects and arrays both show up here.
{
"web": {
"image": "nginx:latest",
"ports": ["80:80", "443:443"],
"environment": {
"NODE_ENV": "production",
"LOG_LEVEL": "warn"
}
}
}
web:
image: nginx:latest
ports:
- "80:80"
- "443:443"
environment:
NODE_ENV: production
LOG_LEVEL: warn
Package.json Scripts Block
Pulling script definitions out of a package.json for documentation or a CI config.
{
"scripts": {
"dev": "next dev",
"build": "next build",
"test": "jest --coverage"
}
}
scripts:
dev: next dev
build: next build
test: jest --coverage
Who Uses This
Converting JSON pipeline configs to YAML for Kubernetes, GitHub Actions, or Ansible.
Turning API response samples into YAML fixtures for tests or documentation.
Reformatting JSON snippets as YAML for docs where readability matters more than machine parsing.
Learning YAML syntax by seeing how familiar JSON structures map to it side by side.
Common Mistakes
Trailing commas after the last item in an object or array will break the parser. JavaScript allows them, but JSON does not. Remove that final comma before converting.
JSON doesn't support comments, period. If you're pasting JSON with // or /* */ comments, the parser will reject it. Strip them first or use a JSON5-aware tool.
YAML is strict about spaces vs. tabs. This converter outputs spaces (2 or 4, your pick), but if you paste the result into a file that mixes tabs and spaces, YAML parsers will complain. Stick with spaces throughout.
Technical Details
- Processing: 100% client-side — nothing uploaded
- Browser Support: Chrome, Firefox, Safari, Edge
- Indent Options: 2 spaces or 4 spaces
- Max Input: Limited only by browser memory
- Output Quoting: Minimal — strings quoted only when YAML requires it
Frequently Asked Questions
Can I convert YAML back to JSON with this tool?
Not here — this one goes JSON to YAML only. There is a separate YAML-to-JSON converter on the site that handles the reverse direction. Both work the same way: paste, click, copy.
Does the converter preserve the order of keys?
Yes. Keys appear in the YAML output in the exact same order as they are in your JSON. The tool does not sort or rearrange anything — what you put in is what comes out, just in a different format.
What happens if my JSON has duplicate keys?
JSON.parse keeps the last value when keys repeat in the same object. So if you have two "name" keys, only the second one makes it into the YAML. This is standard browser behavior, not a bug in the converter.
Is there a file size limit?
No hard limit. The conversion runs in your browser, so it depends on how much memory your device has. Files under 10 MB convert instantly. Larger files work too but might take a second or two.
Why are some strings quoted in the YAML but not others?
YAML has reserved characters and patterns. A string like "true" would be read as a boolean, and "3:00" looks like a sexagesimal number. The converter quotes strings only when leaving them bare would change their meaning. Plain text stays unquoted for cleaner output.