YAML to JSON Converter
Paste YAML to instantly convert it to formatted JSON. Handles nested structures, arrays, multi-line strings, comments, and anchors. Useful for converting Kubernetes configs, CI/CD pipelines, Docker Compose files, and any YAML-based configuration into JSON for use in APIs or code.
How to Convert YAML to JSON
- 1Paste your YAML content into the input area
- 2Click 'Convert to JSON' — errors appear if the YAML is invalid
- 3The formatted JSON output appears on the right
- 4Copy the JSON to use in APIs, code, or other tools
Key Benefits
- Handles nested objects, arrays, anchors, and multi-line strings
- Formatted JSON output with 2-space indentation
- Clear error messages when YAML syntax is invalid
- Runs entirely in your browser — your data never leaves your device
Frequently Asked Questions
What is the difference between YAML and JSON?
YAML is designed for human-readable configuration files: it uses indentation instead of braces, allows comments, supports anchors for reuse, and is more concise for complex nested structures. JSON is a strict data interchange format: no comments, explicit braces and brackets, all strings in double quotes. Valid JSON is also valid YAML, but YAML adds many features JSON does not have.
Will comments in my YAML appear in the JSON?
No. Comments in YAML (lines starting with #) are not part of the data model and are discarded during parsing. The resulting JSON will contain only data values. This is expected — JSON does not support comments.
What are common YAML to JSON conversion errors?
The most common issues are: indentation errors (mixing tabs and spaces — YAML requires consistent spaces only), duplicate keys (may silently overwrite data), and special characters in unquoted strings that YAML interprets as syntax — colons, dashes, square brackets, and curly braces. If you see a parse error, check that indentation uses only spaces and that values containing these characters are quoted.
Can I use this to convert Kubernetes or Docker Compose files?
Yes. Kubernetes manifests and Docker Compose files are standard YAML and convert cleanly to JSON. Kubernetes accepts both YAML and JSON for resource definitions — the API processes them identically. JSON output is also useful for scripting with kubectl or parsing configs in code that expects JSON.
What happens to YAML anchors and aliases?
YAML anchors (&name) and aliases (*name) are resolved during parsing — the alias is replaced with a copy of the anchored value. The resulting JSON will contain fully resolved values with no reference to the original anchor names. Repeated structures that used anchors will appear as duplicated values in the JSON.
What is the difference between YAML, JSON, and TOML for configuration files?
YAML is the most expressive: comments, multi-document files, anchors, complex nesting — common in Kubernetes, GitHub Actions, and Ansible. JSON is strict and universally supported but verbose and comment-free — common in package managers, APIs, and browser tools. TOML is flat and simple, optimised for human-written config — common in Rust (Cargo.toml), Python (pyproject.toml), and Hugo. Choose based on what your tooling expects and whether human editability or portability matters more.