YAML → JSON
Convert YAML to JSON online
Paste YAML, get valid JSON back. Free browser-based converter with support for anchors, multi-doc streams, and pretty-printed output. Nothing uploaded.
Last updated:
[object Object]
[object Object]
[object Object]
Open the YAML → JSON converter
Runs entirely in your browser. No signup, no upload.
Launch converter →Example: YAML → JSON
Input (.yaml)
# docker-compose snippet
services:
web:
image: nginx:latest
ports:
- "80:80"
environment:
ENV: production
REPLICAS: 3
db:
image: postgres:16 Output (.json)
{
"services": {
"web": {
"image": "nginx:latest",
"ports": ["80:80"],
"environment": { "ENV": "production", "REPLICAS": 3 }
},
"db": { "image": "postgres:16" }
}
} How to convert YAML to JSON manually
Prefer scripting this in a pipeline? Here are the most common CLI and library approaches.
Python one-liner
python -c "import yaml,json,sys; print(json.dumps(yaml.safe_load(sys.stdin), indent=2))" < in.yaml > out.json Node.js one-liner
node -e "const y=require('js-yaml');const fs=require('fs');console.log(JSON.stringify(y.load(fs.readFileSync('in.yaml','utf8')),null,2))" > out.json yq (recommended for CLI pipelines)
yq -o=json '.' in.yaml > out.json Frequently asked questions
Will my YAML comments be preserved?
No — the JSON spec has no concept of comments, so every converter drops them. If you need to keep documentation, use a separate Markdown file or a README alongside your config.
My YAML has `!!timestamp` tags. What happens?
We parse YAML-specific tags (timestamps, binary, custom) and serialize them as ISO 8601 strings or base64 in JSON. If you need strict round-trip fidelity, use a format like BSON or MessagePack instead.
What about multi-document YAML streams?
YAML can contain multiple documents separated by `---`. We convert them into a JSON array where each element is one document. If there's only one document, we emit it as a bare object for convenience.
How is this different from `yq` or `jq`?
Functionally equivalent for most inputs — but zero install, no shell required, and works on your phone. `yq` is still better for scripted pipelines; this page is better for one-off conversions and teaching.
Does it flag YAML parse errors?
Yes. If your YAML has indentation mismatches, unclosed flow collections, or invalid escapes, the tool shows the line number and a human-readable message before producing any JSON output.
