"category": "format-converter",
YAML to JSON Converter
"tldr": Paste any YAML document and get pretty-printed JSON - anchors resolved, full YAML 1.2 support, errors reported with line numbers.
Convert YAML documents into pretty-printed JSON. Paste a Kubernetes manifest, GitHub Actions workflow, Docker Compose file, or any YAML config and get equivalent JSON you can feed to APIs, scripts, or JSON-only tools like jq.
The parser supports the full YAML 1.2 spec: anchors and aliases are resolved, multi-line strings are joined correctly, and YAML-specific values like unquoted dates and booleans map to their closest JSON equivalents. Syntax errors are reported with the line number so you can fix them fast.
How to convert YAML to JSON
- 1Paste your YAML into the input panel - indentation defines the structure, so keep it intact.
- 2The parser validates the document and reports any syntax error with its line number.
- 3Valid YAML is converted to JSON with 2-space pretty-printing.
- 4Copy the JSON or download it as a .json file.
Convert YAML to JSON in code
import json, yaml # pip install pyyaml
with open("config.yaml") as f:
data = yaml.safe_load(f)
print(json.dumps(data, indent=2))import yaml from "js-yaml"; // npm install js-yaml
const data = yaml.load(yamlString);
const json = JSON.stringify(data, null, 2);Frequently asked questions
What happens to YAML anchors and aliases?
Anchors (&name) and aliases (*name) are resolved during parsing, so the referenced content is duplicated into each place it is used. JSON has no reference syntax, so this expansion is the correct and expected behavior.
Why did the value "no" become false?
This tool parses YAML 1.2 where only true/false are booleans, so "no" stays a string. If a different tool turned yes/no/on/off into booleans, it was using the older YAML 1.1 rules - quoting the value always keeps it a string.
Can I convert multi-document YAML files?
Files with multiple documents separated by --- convert one document at a time. Paste each section separately, or split the file first. Support for wrapping multiple documents into a JSON array is a common follow-up step in a script.
Are comments preserved?
No - JSON has no comment syntax, so YAML comments (# ...) are dropped during conversion. If you need to keep annotations, move them into a real field like "_comment" before converting.
Last updated:
You might also need
Free and in-browser, like everything on JSON Console. Browse all tools →