YAML to JSON Converter
Turn YAML into strict JSON, resolving anchors, aliases and merge keys along the way.
Processed locally in your browser/ Your data stays in your browser.
What is YAML to JSON Converter?
YAML is a superset-like format designed for humans; JSON is what APIs and most programming languages parse natively. Converting between them is a daily task when working with Kubernetes, OpenAPI, CI files or configuration.
This converter parses your YAML 1.2 with the safe core schema, expands aliases and (optionally) merge keys, and writes JSON with the indentation you choose and optional sorted keys. If the file contains several documents separated by ---, the output is an array with one item per document. Integers larger than JavaScript can hold are written exactly, .inf and .nan become null with a warning, and custom tags are never executed.
How does it work?
- Paste your YAML.
- Choose the JSON indentation, decide whether to sort keys and whether to resolve << merge keys.
- Read the warnings if something could not be represented in JSON.
- Copy or download the JSON, or Swap to convert it back to YAML.
Common use cases
- Feeding a YAML configuration to a tool or API that only accepts JSON.
- Inspecting what a Kubernetes or Compose file looks like after anchors and merges are expanded.
- Converting an OpenAPI YAML spec to JSON for a code generator.
- Turning multi-document YAML into a JSON array.
Examples
Try this input in the tool above:
defaults: &defaults adapter: postgres host: localhost pool: 5 development: <<: *defaults database: dev_db test: <<: *defaults database: test_db pool: 1
{
"defaults": {
"adapter": "postgres",
"host": "localhost",
"pool": 5
},
"development": {
"adapter": "postgres",
"host": "localhost",
"pool": 5,
"database": "dev_db"
},
"test": {
"adapter": "postgres",
"host": "localhost",
"pool": 1,
"database": "test_db"
}
}Privacy
YAML to JSON Converter runs entirely in your browser. The text or files you provide are processed on your device and are not uploaded, logged or stored on our servers.
Limitations
JSON has no comments, so they are lost. YAML features without a JSON equivalent (timestamps, binary, non-string keys) are converted to strings or Base64, and circular aliases become null.
Frequently asked questions
What happens with anchors and aliases?
They are resolved: every alias is replaced by a copy of the anchored value. The number of alias expansions is limited to stop “billion laughs” documents.
How are multiple documents handled?
A stream with several --- separated documents produces a JSON array with one element per document. A single document produces the value itself.
Are big numbers preserved?
Yes. Integers are parsed exactly and written digit for digit, so 12345678901234567890 does not become 12345678901234567000.
Related tools
JSON to YAML Converter
Turn JSON into readable block-style YAML, with strings quoted only when necessary.
JSON & Data
YAML Formatter & Beautifier
Re-indent and normalise a YAML file while keeping comments, anchors and multi-document structure.
JSON & Data
YAML Validator
Check that a YAML file is valid and find the exact place where it breaks.
JSON & Data
JSON Formatter & Beautifier
Turn a minified or messy JSON document into readable, consistently indented text, with a precise error message if the JSON is invalid.
JSON & Data
XML to JSON Converter
Turn an XML document into JSON, keeping attributes, repeated elements and text content in a predictable structure.
JSON & Data
JSON to XML Converter
Turn a JSON document into well-formed XML with control over the root element, attributes and formatting.
JSON & Data
JSON Validator
Check whether a piece of text is valid JSON and locate the exact character where it goes wrong.
JSON & Data