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.