How to Convert YAML to JSON: Complete Guide
Last updated: 2026-04-14
YAML has become the configuration language of choice for Kubernetes manifests, Docker Compose files, GitHub Actions workflows, and Ansible playbooks. Yet most programming languages and APIs consume JSON natively. When you need to validate a YAML config programmatically, feed it into a REST endpoint, or store it in a document database, converting to JSON is the pragmatic move.
Step-by-Step: Convert YAML to JSON with Convertee
- Open Convertee and choose YAML as source and JSON as target.
- Paste your YAML content into the input panel, or drag-and-drop a
.yaml/.ymlfile. - Adjust the JSON indent level if needed (2 spaces, 4 spaces, tabs, or minified).
- Press Convert (Cmd+Enter).
- Copy the JSON output or download it as a
.jsonfile.
Your YAML is parsed and converted entirely in the browser — no data leaves your machine.
Understanding the Formats
YAML
YAML (YAML 1.2) is a human-friendly data serialization language. It uses indentation to denote structure (no curly braces or brackets), supports comments with #, anchors and aliases for reuse, and multi-line strings with block scalars (| and >). YAML is a strict superset of JSON — every valid JSON document is also valid YAML.
JSON
JSON (RFC 8259) trades YAML's human readability for strict, unambiguous machine parsing. No comments, no anchors, no multi-line strings — but universal support across every programming language and tool. This makes JSON the safer choice for data interchange and API payloads.
Before / After Example
Input YAML:
server:
host: 0.0.0.0
port: 8080
tls:
enabled: true
cert: /etc/ssl/cert.pem
database:
driver: postgres
connection:
host: db.example.com
port: 5432
name: myappOutput JSON:
{
"server": {
"host": "0.0.0.0",
"port": 8080,
"tls": {
"enabled": true,
"cert": "/etc/ssl/cert.pem"
}
},
"database": {
"driver": "postgres",
"connection": {
"host": "db.example.com",
"port": 5432,
"name": "myapp"
}
}
}Common Use Cases
- Kubernetes config validation. You write a complex k8s manifest in YAML and want to validate it with a JSON Schema-based tool or paste it into a policy engine that accepts JSON.
- CI/CD debugging. GitHub Actions and GitLab CI configs are YAML. Converting to JSON lets you programmatically inspect specific fields, compare two configs with standard JSON diff tools, or pipe the result into
jq. - API request body preparation. Your application config is in YAML, but the API you are calling expects a JSON payload. Converting once avoids maintaining duplicate files.
- Documentation and training. When teaching students or onboarding new team members, showing the YAML-to-JSON equivalence clarifies how indentation maps to nested objects.
Options and Configuration
| Option | Default | What It Does |
|---|---|---|
| JSON indent | 2 spaces | Sets the indentation of the output. Choose 2 or 4 spaces, tabs, or minified. |
| Resolve anchors | On | YAML anchors (&name) and aliases (*name) are resolved into their full values in the JSON output. |
| Multi-document | First only | If the YAML contains multiple documents (separated by ---), this controls whether to convert only the first document or wrap all documents in a JSON array. |
Frequently Asked Questions
- Does Convertee support YAML anchors and aliases?
- Yes. YAML anchors (&name) and aliases (*name) are resolved automatically during conversion. The JSON output contains the fully expanded values.
- How are YAML comments handled?
- JSON does not support comments, so YAML comments (lines starting with #) are stripped during conversion. The data values are preserved exactly as specified.
- Can I convert multi-document YAML files?
- By default, Convertee converts only the first document. You can enable the 'Multi-document' option to wrap all documents in a JSON array.
- Is my YAML data uploaded anywhere?
- No. The YAML is parsed and converted to JSON entirely in your browser. No data is transmitted over the network.