YAML to JSON — Convert YAML Configuration to JSON Online
Convert YAML data to JSON format. Resolves anchors, aliases, and merge keys. Configurable indentation, runs entirely in your browser.
YAML and JSON are sibling formats — YAML is JSON with a more human-friendly syntax, and every valid JSON file is also a valid YAML file. The conversion from YAML to JSON is the most common data-format conversion in DevOps because YAML is the language humans write (Kubernetes manifests, CI pipelines, application config) and JSON is the language machines read (API responses, Terraform state, cloud provider CLI output). The conversion is almost trivial — YAML is a superset of JSON — but YAML adds features that need to be resolved before JSON can consume them: anchors and aliases (DRY references within a file), merge keys (deep-merging of shared configuration blocks), and a richer type system (timestamps, hex numbers, binary data).
Anchors and aliases are the YAML feature that causes the most confusion in conversion. A YAML anchor (&defaults) defines a reusable block, and an alias (*defaults) inserts it wherever the alias appears. The JSON output contains the fully expanded data — anchors and aliases are a YAML authoring convenience, not a data model, and JSON has no equivalent. Merge keys (<<: *defaults) are resolved by deep-merging the aliased mapping into the current mapping, with the current mapping’s keys taking precedence. The resolution is handled automatically during conversion, and the JSON output is the merged result.
For a final hand-off: if the JSON output is feeding into a programming language, pair the YAML-to-JSON conversion with the appropriate JSON-to-Code generator (JSON to TypeScript for frontend types, JSON to Python for data processing, JSON to Go for backend structs). If the JSON needs to become configuration for a different tool (Ansible inventory, Terraform variables, GitHub Actions inputs), the JSON tool is the right intermediate format because every config-management tool has a JSON parser. If you need the reverse conversion (JSON to YAML), the JSON-to-YAML tool on this site handles it with the same indentation and formatting controls.
How to use
Paste your YAML
Drop a YAML string or file into the input. The parser handles YAML 1.2, including multi-document YAML (separated by `---`). Each document is converted to a separate JSON object.
Choose JSON formatting
Default is 2-space indentation with pretty-printing. Switch to compact mode for minimal whitespace (machine-to-machine exchange). Toggle between 2 and 4 spaces for style-guide compliance.
Copy or download the JSON
Copy the JSON to your clipboard, or download as a .json file. The output is valid JSON (RFC 8259) and parses correctly in every language's standard library.
Frequently asked
Does the converter handle YAML anchors and aliases?
Yes. YAML anchors (`&ref`) and aliases (`*ref`) are resolved to their expanded values. Merge keys (`<<: *ref`) are also resolved. The JSON output contains the expanded data — anchors and aliases are a YAML authoring convenience, not a data structure.
How does the converter handle YAML multi-document files?
Multi-document YAML (documents separated by `---` and optionally terminated by `...`) is converted to a JSON array, with each YAML document becoming one element. A single-document file produces a single JSON value, not an array.
What happens to YAML data types like timestamps and booleans?
YAML's type system is richer than JSON's. Timestamps (`2024-01-15`) are converted to ISO-8601 strings (their most portable JSON representation). Booleans (`true`, `false`, `yes`, `no`, `on`, `off`) are normalised to JSON `true` and `false`. Null values (`~`, `null`, empty) become JSON `null`.
Is the key order preserved from the YAML input?
Yes. YAML 1.2 mappings preserve key insertion order, and the JSON output follows that order. However, JSON specification does not guarantee key order, so consumers that re-sort keys may change the order. The tool itself preserves it.
Limitations
- No YAML custom tags beyond standard libraryYAML tags like `!!python/object` or `!!java/com.example.Bean` are parsed as strings but not deserialised. The tag prefix is preserved in a `_tag` key if the 'preserve tags' option is enabled.
- Large YAML files may produce deeply nested JSONThe JSON output mirrors the YAML structure exactly, which can produce dozens of nesting levels. Some JSON consumers (particularly older parsers) have stack-depth limits that may reject deeply nested output.
- Multi-document YAML to single JSON array is lossyThe YAML document separator comments and metadata are lost when the documents are combined into a JSON array. The semantic grouping of multiple YAML documents in one file does not carry over to JSON.
Platform notes
- macOS
- CLI equivalent: `yq eval -o json input.yaml` (from the yq package via Homebrew). The browser tool is the right pick for ad-hoc conversion when yq is not installed or the YAML is pasted from a chat window.
- Linux
- CLI equivalent: `python3 -c 'import yaml,json; print(json.dumps(yaml.safe_load(open("file.yaml")), indent=2))'`. The browser tool saves the quoting and escaping chore for complex YAML.
- Web
- All processing runs client-side. No YAML data is uploaded. Works offline after page load.