YAML to JSON Converter
Convert YAML to JSON format instantly. Handles nested structures, arrays, and all YAML types. Free online converter.
What is YAML to JSON Converter?
A YAML to JSON converter transforms YAML (YAML Ain't Markup Language) configuration data into JSON format. YAML is popular for configuration files (Docker Compose, Kubernetes, GitHub Actions, Ansible) because it's more human-readable than JSON — it uses indentation instead of braces and doesn't require quotes around most strings. However, many tools, APIs, and programming languages work better with JSON. This tool converts between the formats instantly, handling all YAML features including multi-line strings, anchors, aliases, and complex nested structures.
How It Works
The tool uses a YAML parser that interprets indentation-based structure, recognizes YAML-specific types (dates, booleans, nulls, numbers), processes multi-line strings (both literal | and folded > styles), and resolves anchors (&) and aliases (*). The parsed data structure is then serialized as formatted JSON with proper indentation. It handles edge cases like strings that look like numbers or booleans in YAML, ensuring the conversion produces correctly typed JSON output.
Examples
server:
host: localhost
ports:
- 80
- 443{
"server": {
"host": "localhost",
"ports": [80, 443]
}
}country: NO enabled: yes
{
"country": false,
"enabled": true
}
// Quote the values to keep them as strings:
// country: "NO"Common Use Cases
- •Converting Kubernetes YAML manifests to JSON for API calls to the K8s API server
- •Transforming Docker Compose files to JSON for programmatic manipulation
- •Converting GitHub Actions workflow YAML to JSON for validation and processing
- •Preparing YAML configuration for tools that only accept JSON input format
- •Debugging YAML parsing issues by converting to JSON to verify the interpreted structure
- •Converting Ansible playbooks or CloudFormation YAML templates for JSON-based tooling
Frequently Asked Questions
What YAML features are supported?▼
All standard YAML including nested objects, arrays, anchors, multiline strings, and type casting.
What YAML features are lost when converting to JSON?▼
Comments, anchors and aliases (`&name` and `*name`, which are expanded inline), explicit type tags, and multi-document files separated by `---`. JSON has no representation for any of them, so the output is a flattened snapshot of the data.
Why does my YAML fail to parse?▼
In order of likelihood: a tab character used for indentation, which is illegal; inconsistent indentation depth; a missing space after a colon, since `key:value` is one string while `key: value` is a mapping; and an unquoted string containing `:` or `#`, which are structural characters.
How are dates and timestamps converted?▼
YAML can type an unquoted `2024-01-15` as a date object, whereas JSON has no date type and must render it as a string. Quote dates in the YAML source if you want to control the exact string that appears in the JSON.
What happens to a multi-document YAML file?▼
JSON has no multi-document concept, so only the first document converts. To keep everything, wrap the documents in a JSON array yourself, or convert each one separately.
Are duplicate keys allowed?▼
The YAML specification forbids them, though many parsers accept the file and silently keep the last value — a genuinely dangerous behaviour in configuration. Neither format will warn you reliably, so check for duplicates before converting.
Related Tools
More from Converters:
JSON to YAML Converter
Convert JSON to YAML format instantly. Clean, readable YAML output. Free online JSON to YAML converter.
JSON Formatter
Format, validate, and beautify JSON data online. Free JSON formatter with syntax highlighting, error detection, and minify option.
CSV to JSON Converter
Convert CSV data to JSON format instantly. Headers become keys. Free online CSV to JSON converter with copy and download.