Convert YAML to JSON instantly, right in your browser
Paste any YAML config, API response, or data file above and get clean, valid JSON back in one click. No sign-up, no file uploads – your data never leaves your device.
# YAML input
server:
host: api.example.com
port: 8080
tls: true
tags:
- production
- v2→ Converts to:
{
"server": {
"host": "api.example.com",
"port": 8080,
"tls": true
},
"tags": [
"production",
"v2"
]
}Note: The # comment is dropped – JSON has no comment syntax. Braces replace indentation, and all keys get double quotes.
How to use this YAML to JSON converter
- Paste your YAML into the input panel above.
- The JSON output appears automatically on the right (or click Convert if prompted).
- Review the result – check that nested structures and data types look right.
- Hit Copy to grab the JSON, or download it as a
.jsonfile.
Worked example: Kubernetes config to JSON
Say you have this YAML snippet from a Kubernetes deployment manifest:
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
labels:
env: staging
spec:
replicas: 3
selector:
matchLabels:
app: my-appThe converter outputs this JSON:
{
"apiVersion": "apps/v1",
"kind": "Deployment",
"metadata": {
"name": "my-app",
"labels": {
"env": "staging"
}
},
"spec": {
"replicas": 3,
"selector": {
"matchLabels": {
"app": "my-app"
}
}
}
}Notice that replicas stays a number (not a string) – the converter preserves data types correctly.
How to convert YAML to JSON in code
If you need this in a script or build pipeline, here are the shortest working approaches in two popular languages.
Python
Requires the PyYAML package (pip install pyyaml).
import yaml, json
with open('config.yaml') as f:
data = yaml.safe_load(f)
print(json.dumps(data, indent=2))JavaScript (Node.js)
Requires the js-yaml package (npm install js-yaml).
const yaml = require('js-yaml');
const fs = require('fs');
const data = yaml.load(fs.readFileSync('config.yaml', 'utf8'));
console.log(JSON.stringify(data, null, 2));Both snippets read a file, parse the YAML into a native object, then serialize it back out as formatted JSON.
How the conversion works
YAML (YAML Ain't Markup Language) and JSON share the same underlying data model – objects (key-value maps), arrays, strings, numbers, booleans, and nulls. That's why converting between them is lossless for data, with one important exception: YAML comments are dropped, because JSON has no comment syntax at all.
The converter parses your YAML into an in-memory tree, then re-serializes it as JSON with double-quoted keys, curly braces for objects, and square brackets for arrays – following the JSON specification. The YAML side follows the YAML 1.2 spec. Everything runs in your browser with JavaScript – zero server calls, zero data storage.
When to use YAML to JSON conversion
| Situation | Why convert? |
|---|---|
| Sending data to a REST API | APIs almost always expect JSON, not YAML. |
Using a tool that only reads JSON (e.g. jq, many CI config validators) | Convert once, then process with your JSON-native toolchain. |
| Debugging a config file | JSON's explicit braces and quotes can make structure easier to spot-check. |
| Storing config in a JSON-only database field | Keeps the schema consistent with other entries. |
When not to convert
- You need to keep comments. Human-readable comments in YAML (lines starting with
#) are lost permanently when you convert to JSON. - The target system reads YAML natively. Docker Compose, GitHub Actions, Ansible, and Kubernetes all accept YAML directly – no conversion needed.
- Your YAML uses anchors or aliases. These YAML-only features (like
&anchorand*alias) are expanded and flattened during conversion; the shorthand is gone in the output.
Need to go the other direction? Try the JSON to YAML Converter to turn JSON objects back into clean, readable YAML.
Bottom line: paste your YAML above and get valid JSON in seconds – no account, no waiting, nothing stored.