YAML to JSON
Convert YAML to JSON format online instantly. Free YAML to JSON converter for parsing configuration and data files accurately.
About YAML to JSON Converter
Convert YAML configuration files to JSON format. Supports nested objects, arrays, booleans, numbers, and special YAML values like null (~), yes/no, and on/off.
How to Use YAML to JSON
Paste your YAML
Paste your YAML configuration or document into the input editor on the left. Or click Upload to pick a .yaml/.yml file from disk.
View JSON output
The converted JSON appears instantly in the output panel. Comments are stripped (JSON doesn't support them), but structure, types, anchors, and aliases are preserved.
Adjust formatting (optional)
Choose 2-space, 4-space, or tab indentation for the JSON output. Most APIs and tools accept any well-formed JSON regardless of indent style.
Copy or download
Click Copy to put the JSON on your clipboard, or Download to save as a .json file. Use it in API requests, programmatic processing, or any JSON-consuming context.
When to Use YAML to JSON
Processing Kubernetes manifests programmatically
Kubernetes resources are typically authored in YAML but need to be processed (validated, transformed, generated) by code. Convert YAML manifests to JSON to manipulate with kubectl's --output=json, jq, or any JSON-aware tooling. Round-trip back to YAML for kubectl apply.
Reading CI/CD configs in build scripts
GitHub Actions, GitLab CI, CircleCI configs are YAML. To extract job names, validate triggers, or generate documentation from these configs, convert to JSON first — JSON parsers exist in every language and handle deeply nested structures cleanly.
Migrating from YAML APIs to JSON APIs
Some legacy services accept YAML (Ansible Tower, older config services) while new ones prefer JSON. Use this converter as a transformation layer when migrating between them or building bridge services that accept both formats.
Converting Helm chart values for templating
Helm chart values.yaml files drive complex templated deployments. Converting to JSON lets you process values with jq, validate schemas with JSON Schema validators, or generate documentation describing all available configuration options.
YAML to JSON Examples
Simple YAML conversion
name: Alice
age: 30
skills:
- JavaScript
- TypeScript{
"name": "Alice",
"age": 30,
"skills": [
"JavaScript",
"TypeScript"
]
}Basic YAML mapping (name, age) becomes JSON object. The list (skills) becomes JSON array. Indentation in YAML maps to nesting in JSON. Numbers stay numbers, strings stay strings — types are preserved across formats.
Nested config
server:
host: localhost
port: 8080
cors:
enabled: true
origins:
- https://app.com
- https://admin.app.com{
"server": {
"host": "localhost",
"port": 8080,
"cors": {
"enabled": true,
"origins": [
"https://app.com",
"https://admin.app.com"
]
}
}
}Nested YAML mappings become nested JSON objects. Each indentation level maps to one nesting level. Boolean (true) and arrays of strings convert correctly. The output is significantly more verbose than YAML — that's the cost of JSON's structure.
YAML anchors resolved
defaults: &defaults
retries: 3
timeout: 30
production:
<<: *defaults
host: prod.com
staging:
<<: *defaults
host: staging.com{
"defaults": { "retries": 3, "timeout": 30 },
"production": { "retries": 3, "timeout": 30, "host": "prod.com" },
"staging": { "retries": 3, "timeout": 30, "host": "staging.com" }
}YAML anchors (&defaults) and aliases (<<: *defaults) are resolved during conversion. The JSON output contains the expanded values for each environment. This loses the DRY-ness of YAML but produces fully-qualified JSON that any parser can read without anchor support.
Tips & Best Practices for YAML to JSON
- 1.After converting, validate the JSON output with a JSON validator. Some YAML edge cases (very long strings, special chars) can produce JSON that needs verification.
- 2.Comments are lost during conversion. If your YAML has important documentation in comments, save it separately or convert to JSONC/JSON5 (which support comments) instead of standard JSON.
- 3.For round-trip workflows (YAML → JSON → YAML), be aware that idempotent conversion isn't guaranteed for all YAML features. Anchor resolution especially is one-way — the resolved JSON can't recreate the original anchors.
- 4.Numbers in YAML can be ambiguous (e.g., '01' might be an octal in YAML 1.1 but an error in 1.2). The converter follows YAML 1.2 rules. If you have unusual numbers, verify they convert as expected.
- 5.For Kubernetes manifests specifically, kubectl convert (between API versions) operates on JSON internally. This converter is useful for manual inspection but kubectl handles version migrations natively.
- 6.Multi-document YAML (separated by ---) becomes either an array of JSON objects or separate JSON files depending on the converter's mode. Check options before relying on a specific output structure.
Frequently Asked Questions
Related Tools
JSON to YAML
Convert JSON to YAML format online instantly. Free JSON to YAML converter for configuration files with clean indented output.
JSON to XML
Convert JSON to XML format online instantly. Free JSON to XML converter with proper nesting, attributes, and formatted output.
XML to JSON
Convert XML to JSON format online instantly. Free XML to JSON converter with proper structure mapping and clean formatted output.
JSON to CSV
Convert JSON arrays to CSV format online. Free JSON to CSV converter for exporting data to spreadsheets with proper formatting.
CSV to JSON
Convert CSV data to JSON format online. Free CSV to JSON converter with header detection and properly structured array output.
CSV JSON Converter
Convert between CSV and JSON formats online with bidirectional support. Free converter with delimiter options and data preview.