YAML to JSON
Free web tool: YAML to JSON
About YAML to JSON
The YAML to JSON Converter is a free, browser-based tool that converts YAML to JSON and JSON back to YAML in real time. The tool uses a custom-built YAML parser that handles the most common YAML constructs: nested mappings, block sequences, inline arrays ([a, b, c]), boolean and null literals (true/false/null/~), integer and float scalars, quoted strings, block scalars (| and >), and comment lines. No external YAML library is required — the entire parser runs as client-side JavaScript.
This tool is used by DevOps engineers, backend developers, and platform engineers who frequently switch between YAML configuration files (Kubernetes manifests, Docker Compose, CI/CD pipelines, Helm charts, Ansible playbooks) and JSON payloads for APIs or debugging tools. The split-panel layout shows YAML on the left and JSON on the right, with explicit conversion buttons for both directions — YAML to JSON and JSON to YAML.
The JSON to YAML conversion produces clean YAML output using a recursive serializer. Objects are expanded into key: value pairs, arrays use the - list item prefix, and multi-line strings or values containing special characters (colons, hashes, quotes) are automatically wrapped in double quotes. A live sample is pre-loaded when the tool opens, making it easy to understand the expected input format without reading documentation.
Key Features
- Bidirectional conversion: YAML to JSON and JSON to YAML with separate action buttons
- Custom YAML parser supporting nested mappings, block sequences, and inline arrays
- Handles YAML boolean literals (true/false/True/False/TRUE/FALSE) and null (~)
- Integer and float scalars are converted to native JSON number types
- Block scalar support for pipe (|) and fold (>) multi-line string operators
- JSON to YAML output auto-quotes strings with colons, hashes, or double quotes
- Split-panel editor with individual Copy buttons for YAML and JSON sides
- Pre-loaded sample data (name, version, features, database config) for immediate reference
Frequently Asked Questions
Does this tool support all YAML features?
The tool covers the most common YAML constructs used in configuration files: nested objects, lists, block scalars, booleans, null, numbers, quoted strings, and inline arrays. Advanced YAML features such as anchors (&), aliases (*), merge keys (<<), and multi-document streams (---) are not currently supported.
How do I convert YAML to JSON?
Paste or type your YAML into the left panel, then click the "YAML → JSON" button. The converted JSON appears in the right panel. You can then click Copy to copy the JSON or continue editing in either panel.
How do I convert JSON to YAML?
Paste or type valid JSON into the right panel, then click the "JSON → YAML" button. The converted YAML appears in the left panel. The output uses 2-space indentation and automatically quotes strings that contain special characters.
What happens if I enter invalid YAML?
An error message appears at the top of the tool describing what went wrong, such as a parsing error for unexpected characters or structure. The panels retain their content so you can correct the input without losing your work.
Are YAML comments preserved in the JSON output?
No. YAML comments (lines starting with #) are stripped during parsing because JSON has no comment syntax. If you convert back to YAML, the comments will not be present in the output.
How are YAML booleans handled?
YAML boolean literals true, True, TRUE, false, False, and FALSE are all converted to their JSON boolean equivalents (true and false). Similarly, null, Null, NULL, and ~ are converted to JSON null.
Can I convert nested Kubernetes or Docker Compose YAML?
Yes. The parser handles deeply nested mappings as seen in Kubernetes manifests and Docker Compose files. However, YAML anchors and aliases (commonly used in complex manifests) are not supported. For those, consider a full YAML library like js-yaml.
Is the conversion lossless when going from YAML to JSON and back?
Mostly yes for simple structures. However, YAML comments, anchor/alias definitions, and explicit type tags are lost in the round-trip. Numeric strings that look like numbers (e.g., "1.0" in YAML) may be parsed as numbers in JSON and then serialized as numbers in YAML.