YAML to JSON Converter
Paste YAML and get formatted JSON, ready for APIs, JavaScript code or JSON Schema validation.
JSON
Convert YAML config files to JSON
YAML is pleasant to write but many tools only accept JSON: REST APIs, JavaScript code, JSON Schema validators and jq all expect it. This converter parses your YAML and prints it as JSON indented with two spaces. Anchors and aliases are expanded into full copies, comments are dropped, and unquoted values are typed the way YAML defines them: numbers become numbers, true and false become booleans, ~ and null become null, and dates become ISO 8601 strings. If the YAML has an indentation or syntax error, the message points to the line and column.
How to use
- Paste your YAML, for example a docker-compose.yml or a GitHub Actions workflow.
- Read the formatted JSON in the output editor, or fix the line reported in the error message.
- Copy the JSON, or press Swap to convert it back to YAML.
Frequently asked questions
- What happens to YAML anchors and aliases?
- They are resolved. Every alias (*name) is replaced with a full copy of the anchored value, because JSON has no way to reference another part of the document.
- Why is my value yes still a string?
- The parser follows YAML 1.2, where only true and false are booleans. yes, no, on and off stay strings; write true or false if you need a boolean.
- Can I convert a file with several documents separated by ---?
- Only one document is converted at a time. Paste each document separately, or merge them into a single YAML list first.
Example: YAML to JSON
YAML input
name: deploy
on:
push:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm test
JSON output
{
"name": "deploy",
"on": {
"push": {
"branches": [
"main"
]
}
},
"jobs": {
"build": {
"runs-on": "ubuntu-latest",
"steps": [
{
"uses": "actions/checkout@v4"
},
{
"run": "npm test"
}
]
}
}
}