YAML to JSON Converter
Paste YAML — get formatted JSON output instantly. Nothing leaves your browser.
How to convert YAML to JSON
- Paste your YAML document into the input field — a config file, Kubernetes manifest, GitHub Actions workflow, or any YAML snippet.
- Click "Convert" — the formatted JSON output appears instantly with all types, nested structures, and aliases resolved.
- Switch to "JSON → YAML" using the toggle above if you need the reverse direction.
- Click "Copy" or "Download .json" to use the output in your application, API, or data pipeline.
- Note: YAML comments and anchor names are not preserved in the JSON output — only their resolved values carry over.
How the YAML to JSON converter works
The converter uses js-yaml, a full-featured YAML parser for JavaScript, running entirely in your browser. When you click Convert, js-yaml parses the YAML document into a JavaScript object — resolving anchors and aliases, applying type coercions, and handling all YAML 1.2 spec features. The result is then serialized to indented JSON using JSON.stringify(). No data leaves your machine — the conversion is purely local.
YAML is a superset of JSON, meaning every valid JSON document is also valid YAML. The reverse is not true: YAML has features (comments, anchors, multi-line strings, multiple documents, custom tags) that have no JSON equivalent. These features are resolved or dropped during conversion.
# Input YAML (Kubernetes-style config):
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
labels:
app: my-app
env: production
spec:
replicas: 3
containers:
- name: app
image: my-app:latest
ports:
- containerPort: 8080
// Output JSON:
{
"apiVersion": "apps/v1",
"kind": "Deployment",
"metadata": {
"name": "my-app",
"labels": { "app": "my-app", "env": "production" }
},
"spec": {
"replicas": 3,
"containers": [
{ "name": "app", "image": "my-app:latest", "ports": [{ "containerPort": 8080 }] }
]
}
}Who uses YAML to JSON conversion
YAML is the dominant format for configuration files — Kubernetes, Docker Compose, GitHub Actions, Ansible, and most CI/CD tools use it. JSON is the dominant format for APIs and data interchange. Converting between them is a daily task for DevOps engineers, backend developers, and anyone working across configuration and runtime boundaries.
- DevOps and SRE teams — converting Kubernetes manifests or Helm chart values to JSON for programmatic processing or API submission.
- CI/CD pipeline authors — extracting structured data from GitHub Actions, GitLab CI, or CircleCI YAML files into JSON for analysis.
- Backend developers — consuming YAML config files in applications that use JSON for their internal data model.
- Infrastructure as Code — converting Ansible playbooks or Pulumi YAML configs to JSON for integration with Terraform or API-driven tools.
- API developers — testing API payloads by quickly converting YAML-formatted examples into JSON for use in curl, Postman, or Insomnia.
- Config migration — moving between YAML-based tools (docker-compose.yaml) and JSON-based alternatives (devcontainer.json).
YAML syntax and its JSON equivalent
YAML supports all JSON data types plus several YAML-specific features. The table below shows how the most common YAML constructs map to JSON. Features with no JSON equivalent are resolved to their closest equivalent or dropped during conversion.
| YAML syntax | JSON equivalent | Notes |
|---|---|---|
| key: value | "key": "value" | Unquoted string |
| key: 42 | "key": 42 | Integer |
| key: 3.14 | "key": 3.14 | Float |
| key: true | "key": true | Boolean (true/false only in YAML 1.2) |
| key: null or key: ~ | "key": null | Null value |
| - item1 - item2 | ["item1", "item2"] | Sequence → JSON array |
| nested: key: val | {"nested":{"key":"val"}} | Mapping → JSON object |
| | literal block | "literal\nblock\n" | Literal block → string with newlines |
| > folded block | "folded block" | Folded block → single-line string |
| &anchor / *alias | (value inlined) | Anchors resolved; names dropped |
| # comment | (dropped) | Comments have no JSON equivalent |
When to convert YAML to JSON — and when to keep YAML
Convert to JSON when:
- Target is an API or web service — REST APIs and most web frameworks expect JSON-encoded payloads, not YAML.
- Programmatic processing in JavaScript — JSON.parse() is native; YAML requires a separate library like js-yaml.
- NoSQL database import — MongoDB, Firestore, and DynamoDB ingest JSON-like documents natively.
- Debugging or type inspection — JSON's strict quoting makes it easier to detect type errors; unquoted YAML values can be ambiguous.
- Tool compatibility — many data pipelines, ETL tools, and SaaS platforms accept only JSON for their import APIs.
Keep YAML when:
- Human readability matters — YAML is less noisy than JSON; no quotes around string keys, no commas between entries.
- Comments are required — YAML supports # comments; JSON does not. Config files with inline documentation must stay as YAML.
- Anchors and aliases are used — DRY config files using &anchor / *alias for repeated values must stay as YAML.
- Multi-document files are needed — YAML supports multiple documents in one file (separated by ---); JSON requires separate files.
- Target tools are YAML-native — Kubernetes, Ansible, Helm, GitHub Actions, and Docker Compose all use YAML as their primary format.
YAML features that don't survive JSON conversion
YAML is a richer format than JSON. When converting to JSON, some information is always lost because JSON has no equivalent constructs. Understanding what is dropped helps you decide whether conversion is appropriate for your use case.
- Comments — all # comment lines are stripped. If your YAML config relies on comments for documentation, store the original YAML file alongside the JSON.
- Anchor names — &anchor declarations are resolved and their values inlined at each *alias reference point. The anchor name itself is dropped from the JSON.
- YAML tags — explicit type tags (!!str, !!int) are applied by the parser but the tag names are not included in the JSON output.
- Multi-document files — YAML files with multiple --- separated documents are not directly supported. Convert each document separately.
- Block style distinctions — the choice between literal (|) and folded (>) block scalars affects whitespace, but both become regular strings in JSON.
# YAML with anchors, aliases, and merge keys:
defaults: &defaults
timeout: 30
retries: 3
production:
<<: *defaults
host: prod.example.com
staging:
<<: *defaults
host: staging.example.com
// Output JSON (anchors resolved, merge keys expanded):
{
"defaults": { "timeout": 30, "retries": 3 },
"production": { "timeout": 30, "retries": 3, "host": "prod.example.com" },
"staging": { "timeout": 30, "retries": 3, "host": "staging.example.com" }
}