YAML to JSON Converter
Data ToolsPaste YAML and get the equivalent JSON, with the line and column of any error.
Processed in your browser. A copy of each run is saved to your past runs so you can reopen it. Privacy
About
What the YAML to JSON Converter does
The YAML to JSON Converter parses YAML with the YAML 1.2 core schema and writes the same data as JSON, indented or minified. Anchors and aliases are expanded, several documents separated by --- become a JSON array or JSON Lines, and custom tags such as CloudFormation's !Ref are kept as text with a note. Invalid YAML shows the line and column of the first error.
Steps
How to use it
- 1Paste YAML, upload a .yaml file, or open a link with ?yaml= in it.
- 2Choose the indent and how several documents should be combined.
- 3Press Convert and copy or download the JSON.
Example
A real run
Input
services:
web:
image: nginx:1.27
ports:
- "8080:80"
environment:
DEBUG: no
db:
image: postgres:16
volumes:
- pgdata:/var/lib/postgresql/data
volumes:
pgdata: {}Output
{
"services": {
"web": {
"image": "nginx:1.27",
"ports": [
"8080:80"
],
"environment": {
"DEBUG": "no"
}
},
"db": {
"image": "postgres:16",
"volumes": [
"pgdata:/var/lib/postgresql/data"
]
}
},
"volumes": {
"pgdata": {}
}
}A docker-compose file as JSON. DEBUG: no stays the string "no" under YAML 1.2, the quoted port mapping stays a string, and the empty pgdata map becomes {}.
Options
Every setting, and when to use it
- Indent
- 2 spaces suits most projects; 4 spaces matches many Python and Java codebases; Minified gives one line for embedding in a request or environment variable.
- Several documents (---)
- Kubernetes and CI files often hold several documents in one file. As a JSON array wraps them in [ ]; As JSON Lines writes one document per line, which tools like jq read one at a time.
Good to know
Common problems and limits
Input up to 5 MB. Anchors and aliases are expanded, but a file that expands more than 10,000 aliases is refused, because that pattern is used to exhaust memory.
Comments are dropped, since JSON has none. Custom tags such as !Ref, !Sub or !GetAtt are kept as text like "!Ref MyBucket", because JSON has no tags.
The YAML 1.2 core schema is used: yes, no, on and off stay strings and dates stay text. Older YAML 1.1 tools read those differently; the FAQ explains why. To check a file without converting it, use the YAML Validator.
Audience
Who uses it
- DevOps engineersTurn a docker-compose file, a Kubernetes manifest or a GitHub Actions workflow into JSON for a script, a policy check or an API call, then tidy it in the JSON Formatter.
- Backend developersConvert an OpenAPI spec written in YAML to JSON for a code generator or a tool that only reads JSON.
- Cloud engineersInspect a CloudFormation or Serverless template as JSON, with its short-form tags kept visible.
FAQ
Frequently asked
What is the difference between YAML and JSON?
Both describe the same kinds of data: maps, lists, strings, numbers, booleans and null. YAML uses indentation and allows comments, anchors and multi-line strings, which makes it pleasant for hand-written config. JSON uses braces and quotes, has no comments and is stricter, which makes it the usual choice for APIs and machine output.
Is all JSON valid YAML?
For practical purposes, yes: YAML 1.2 was designed so that JSON documents are valid YAML. That is why tools that read YAML can usually read a .json file too. The reverse is not true, because YAML has features JSON lacks; to go that way, use JSON to YAML.
Why do yes, no and on change type in some tools?
YAML 1.1 treated yes, no, on, off, y and n as booleans, so a country code NO or a setting value on became true or false. YAML 1.2 dropped that rule. This converter follows 1.2, so they stay strings; PyYAML and some older tools still follow 1.1. Quote such values to be safe everywhere.
What happens to CloudFormation tags like !Ref and !Sub?
JSON has no tags, so each tagged value is kept as text, for example "!Ref MyBucket", and a note lists the tags found. CloudFormation's own JSON form writes these as objects such as {"Ref": "MyBucket"}; convert those by hand or with the AWS CLI if you need deployable JSON.
How do I convert YAML to JSON on the command line?
With yq version 4: yq -o=json file.yaml. In Python with PyYAML: python -c 'import sys, yaml, json; print(json.dumps(yaml.safe_load(sys.stdin), indent=2))' < file.yaml. PyYAML follows YAML 1.1, so it turns no into false.
Is my YAML sent anywhere?
No. It is parsed in your browser with the open-source yaml library. A copy of each conversion is saved to your past runs so you can reopen it, as the Privacy page describes.
Automation: an MCP tool yaml_to_json(yaml) → json and an n8n node are planned for this tool.