YAML JSON Converter
Convert YAML to JSON and JSON to YAML easily. Paste your YAML or JSON below and choose the conversion direction.
YAML and JSON
YAML is JSON with less punctuation - no quotes around keys, no commas, no braces. Indentation defines structure instead. It's popular for configuration files (Docker Compose, Kubernetes, CI/CD pipelines) because it's easier for humans to read and write.
This tool converts between the two formats. Got a JSON config that needs to be YAML? Paste it in. Need to convert a YAML file to JSON for an API? Works both ways.
YAML Gotchas
- Indentation must be consistent (spaces only, not tabs)
- Strings usually don't need quotes, but : or # inside them do
- yes/no/true/false get converted to booleans
Understanding YAML and JSON
JSON (JavaScript Object Notation) uses braces, brackets, and quotes for structure'it's strict but universally supported across programming languages. YAML (YAML Ain't Markup Language) uses indentation for structure, making it more human-readable but sensitive to whitespace. Both represent the same data structures: objects/mappings and arrays/lists.
YAML is popular for configuration files (Kubernetes, Docker Compose, Ansible, GitHub Actions) because it's easier for humans to read and write. JSON is preferred for APIs and data exchange because machines parse it more reliably, and it's JavaScript-native. Our converter handles both directions seamlessly.
Frequently Asked Questions
Why does YAML care about spaces?
YAML uses indentation (typically 2 spaces) to define structure instead of braces and brackets. Each indentation level represents nesting depth. Using tabs or inconsistent spacing causes parsing errors. Many editors have YAML plugins to help maintain correct formatting.
Which format should I use?
Use JSON for APIs, browser data, and programmatic generation. Use YAML for configuration files humans will edit. JSON is more portable and universally supported; YAML is more readable for humans. Many systems accept both'choose based on your audience.
Can YAML represent everything JSON can?
Yes! YAML is actually a superset of JSON'valid JSON is also valid YAML. YAML also adds features like comments, anchors (references), and multi-document streams. However, these extra features don't convert to JSON since JSON doesn't support them.
Why am I getting parsing errors?
Common YAML issues: mixing tabs and spaces, incorrect indentation levels, missing quotes around special strings (strings containing colons need quotes), or unescaped special characters. For JSON: missing commas, trailing commas (invalid in JSON), or unquoted keys.
What tools use YAML commonly?
Kubernetes manifests, Docker Compose files, GitHub Actions workflows, Ansible playbooks, CircleCI configs, Travis CI, and many configuration files use YAML. It's the dominant format for infrastructure-as-code and CI/CD pipelines.
Can I add comments to configuration files?
In YAML, yes! Use # for comments. This is one reason YAML is preferred for configs humans edit. JSON doesn't support comments at all, which is a common complaint. Some tools use .jsonc (JSON with comments) as a workaround.
When You Actually Need This
Kubernetes config files are written in YAML, but when you need to validate the structure programmatically or compare two configs, working with JSON is dramatically easier — JSON has no whitespace ambiguity, no implicit type coercion, and every programming language has a built-in JSON parser. Converting a 200-line Kubernetes deployment YAML to JSON lets you use jq or JSON path tools to extract specific nested values without writing custom YAML parsers. This is especially useful when debugging CI/CD pipelines that template YAML configs — you convert the rendered YAML to JSON to see exactly what values got substituted.
API documentation is another common trigger. Many API specs are written in OpenAPI YAML format because YAML is more readable for humans, but automated tooling often expects JSON. When you're integrating with a code generator or validator that only accepts JSON input, converting your hand-written YAML spec to JSON is a required preprocessing step. The reverse also applies — if you generated a JSON config from tooling and need to make manual edits, converting to YAML first makes the structure far more readable and reduces the risk of bracket-matching errors.