YAML to JSON Converter
Convert YAML to JSON online, for free, in a couple of seconds. Paste or upload a .yaml or .yml file into this YAML to JSON converter and get valid, pretty-printed JSON back instantly — the whole conversion runs locally in your browser, so nothing you paste or upload is ever sent anywhere.
Drop your YAML file here
or
Supports .yaml and .yml files, processed entirely on your device
YAML →JSON
Your converted output will appear here.Conversion notes
What to expect
- Preserves nested objects, arrays, and native types (numbers, booleans, null).
- Pretty-printed with two-space indentation for easy diffing and review.
- Works with typical YAML configuration files and common YAML structures.
Example
site:
name: Aperture Docs
version: 1.4.2
active: true
tags:
- web
- cli
- tools
author:
name: Jane Doe
email: jane@example.com
{
"site": {
"name": "Aperture Docs",
"version": "1.4.2",
"active": true
},
"tags": [
"web",
"cli",
"tools"
],
"author": {
"name": "Jane Doe",
"email": "jane@example.com"
}
}When you need JSON instead of YAML
YAML is pleasant to write by hand, but JSON is what most programs actually exchange. REST APIs, browser code, NoSQL databases and countless SDKs all expect JSON, and every language ships a JSON parser in its standard library. Converting a YAML file to JSON is usually the quickest way to feed a human-authored config into one of those systems.
JSON is also stricter. There are no comments, no anchors, and no implicit type guessing, which makes it a safer format for machine-to-machine hand-offs. If a pipeline keeps choking on a YAML quirk, converting once to JSON and checking the result often shows exactly where the data was being misread.
Calling an API
Turn a YAML request body or fixture into the JSON payload an endpoint expects.
Validating against a schema
JSON Schema validators and many linters consume JSON directly, so convert before you validate.
Seeding a database
MongoDB, Firestore and similar stores import JSON documents, not YAML.
Debugging type surprises
See at a glance whether a value was read as a string, number, boolean or null.
How YAML maps to JSON
These are the exact rules this converter applies. Each result below was generated by the tool itself, so it matches what you will see in the output panel.
Mappings become objects
Each key/value pair turns into a quoted JSON key. Nesting depth is preserved.
server:
host: localhost
port: 8080{
"server": {
"host": "localhost",
"port": 8080
}
}Sequences become arrays
A dash-prefixed list becomes a JSON array in the same order.
tags:
- api
- beta{
"tags": [
"api",
"beta"
]
}Scalars keep their type
Unquoted numbers and booleans stay numeric/boolean; quoted values stay strings, so a leading zero survives.
count: 42
ratio: 0.75
zip: "02134"
owner: null{
"count": 42,
"ratio": 0.75,
"zip": "02134",
"owner": null
}Block strings keep their line breaks
A literal block (|) keeps its newlines, which JSON writes as \n escapes.
description: |
line one
line two{
"description": "line one\nline two\n"
}A trickier example: anchors, aliases, dates and nulls
Real configuration files lean on YAML features that JSON simply doesn't have. This sample defines an anchor (&defaults), reuses it with an alias (*defaults), and includes a date and a null value.
defaults: &defaults
retries: 3
timeout: 30
production: *defaults
staging:
retries: 1
timeout: 10
released: 2026-03-14
owner: ~{
"defaults": {
"retries": 3,
"timeout": 30
},
"production": {
"retries": 3,
"timeout": 30
},
"staging": {
"retries": 1,
"timeout": 10
},
"released": "2026-03-14",
"owner": null
}JSON has no concept of references, so the alias is expanded into a full copy of the anchored values and the anchor itself disappears. The date stays as a plain text string, and the YAML null (~) becomes a real JSON null.
Using the JSON in your code
Once you have the converted file, loading it takes a couple of lines in almost any language. Here it is in Python:
import json
with open("config.json", encoding="utf-8") as f:
config = json.load(f)
print(config["site"]["name"])
print(config["tags"][0])YAML vs JSON at a glance
The two formats describe the same data model, but they make very different trade-offs.
| Feature | YAML | JSON |
|---|---|---|
| Comments | Supported with # | Not allowed |
| Readability | Indentation-based, minimal punctuation | Braces, brackets and quotes everywhere |
| Multi-line text | Block scalars (| and >) | Single line with \n escapes |
| Reuse | Anchors and aliases | None; values are repeated |
| Parser availability | Needs a library in most languages | Built into nearly every language |
Things to watch for when converting to JSON
- Comments in the YAML are dropped, because they are not part of the parsed data.
- Anchors and aliases are expanded, so the JSON can be noticeably longer than the YAML it came from.
- Merge keys (<<) are not applied by this converter and appear as a literal "<<" key, so expand merged values in the YAML first if you rely on them.
- A multi-document YAML file (separated by ---) is returned as a JSON array with one entry per document.
YAML to JSON Converter FAQ
How do I convert YAML to JSON online?
Paste or upload your .yaml or .yml file above, keep JSON selected as the output format, and this online YAML to JSON converter renders valid JSON instantly in the output panel — no installation required.
Does this change my data types?
No. Strings, numbers, booleans, and null values from your YAML are mapped to their equivalent JSON types during conversion.
Can I convert YAML to JSON using Python?
Yes — in Python, load the file with PyYAML (`yaml.safe_load`) and serialize the result with the built-in `json` module (`json.dumps`). This browser-based converter is a faster option when you just need a one-off YAML to JSON conversion without writing or running a script.
Is there a file size limit?
Conversion happens in your browser's memory, so very large files depend on your device rather than a server-imposed limit.
Why does my JSON have escaped newlines?
Block strings written with | or > in YAML contain real line breaks. JSON cannot hold a raw line break inside a string, so each one is written as the two-character sequence \n.
What happens to YAML comments?
They are discarded. Comments are not part of the data the parser produces, and JSON has no syntax to store them.
Can I convert a YAML file with several documents?
Yes. When the input contains multiple documents separated by ---, the converter returns a JSON array containing one element per document and tells you in the notes.
Is there a difference between .yml and .yaml?
No. ".yml" and ".yaml" are just two file extensions for the exact same format — this converter accepts either one, so a "yml to JSON" conversion and a "yaml to JSON" conversion produce identical results.
Related conversions
YAML to JavaScript Object
Want an importable module instead of a data file? Export the same data as a JavaScript object.
Try itYAML to TypeScript
Generate the matching TypeScript interface so the JSON is type-checked in your code.
Try itYAML to CSV
Flat list of records? A CSV is easier to open in a spreadsheet than raw JSON.
Try itGetting an error? Check your input with theYAML Validator, or tidy it first with theYAML Formatter. You can also browse all YAML converters.