Step 1: Add YAML
Paste YAML into the editor, choose Open YAML File, or choose Load Sample YAML. Open YAML File converts as soon as a valid file is read. Load Sample YAML converts immediately.
Paste YAML or open a .yaml or .yml file, then convert YAML to JSON in your browser. The text stays on this page and is not uploaded.
Convert YAML to see JSON here.
This converter reads the editor with a YAML parseDocument step, using YAML 1.2 and the core schema. It then turns that document into a JavaScript value and writes JSON with JSON.stringify and two-space indentation. It converts one YAML document. The JSON is a new document, not a restyle of the YAML source.
Unquoted yes, no, on, and off stay strings. true and false become booleans. That is YAML 1.2, not YAML 1.1. The reverse direction is the JSON to YAML converter, which quotes "yes" when it writes YAML so tools that still follow YAML 1.1 are less likely to treat that word as a boolean.
Parsing, conversion, copy, and download all run in this browser. The YAML is not uploaded. A .yml file is YAML too. The download is converted-data.json.
Paste YAML into the editor, choose Open YAML File, or choose Load Sample YAML. Open YAML File converts as soon as a valid file is read. Load Sample YAML converts immediately.
Pasted YAML needs Convert to JSON. Invalid YAML stays in the editor. The status line explains the problem, and the JSON preview is cleared.
The preview shows JSON with two-space indentation. Editing the YAML clears that preview until you convert again. Copy JSON and Download JSON need a current preview.
Copy JSON copies the JSON already in the preview. Download JSON saves that same text as converted-data.json. Neither button converts again. If the preview is empty, both ask you to convert first. Clear empties both panels.
After a successful parse, the page writes pretty-printed JSON from the JavaScript value. It does not support every YAML feature. Custom tags, merge keys, binary data, and circular aliases are rejected instead of being rewritten into a different JSON value.
Unquoted yes, no, on, off, y, and n stay strings. true and false become JSON booleans. null, ~, and an empty value become JSON null. Quoted text stays text, so "01" does not become the number 1.
Open YAML File accepts .yaml and .yml. Both are read as YAML text. YML to JSON uses the same conversion as YAML to JSON.
A mapping key cannot be repeated. If a key appears twice, conversion stops with YAML mapping keys must be unique. The last value is not kept.
An alias that simply repeats a value is written out in full in the JSON. The JSON does not keep YAML anchors. A circular alias is rejected. Merge keys such as << are not expanded.
Successful output is JSON.stringify with two-space indentation. Download JSON saves converted-data.json.
name: Ada
active: true
score: null
tags:
- yaml
- json
address: {}
notes: []
{
"name": "Ada",
"active": true,
"score": null,
"tags": [
"yaml",
"json"
],
"address": {},
"notes": []
}
Unquoted yes and no stay strings. A quoted number-like value stays text, so "01" does not become the number 1.
flag: yes
other: no
code: "01"
{
"flag": "yes",
"other": "no",
"code": "01"
}
message: |
line1
line2
{
"message": "line1\nline2\n"
}
In YAML 1.2, unquoted yes, on, and off stay strings. true and false become booleans.
flag: yes
power: on
mode: off
ok: true
stop: false
{
"flag": "yes",
"power": "on",
"mode": "off",
"ok": true,
"stop": false
}
Unquoted 01 is a number. Quoted "01" stays a string.
plain: 01
quoted: "01"
{
"plain": 1,
"quoted": "01"
}
All three become JSON null.
a: null
b: ~
c:
{
"a": null,
"b": null,
"c": null
}
The alias is expanded. The JSON contains the repeated value, not a YAML anchor.
city: &c Quetta
home: *c
work: *c
{
"city": "Quetta",
"home": "Quetta",
"work": "Quetta"
}
| keeps a trailing newline. |- strips that final newline. The existing example above uses |, so the JSON string ends with a newline.
plain: |
line1
line2
stripped: |-
line1
line2
{
"plain": "line1\nline2\n",
"stripped": "line1\nline2"
}
The root value does not have to be a mapping. A sequence, string, number, boolean, or null is converted. An unquoted yes as the whole document becomes a JSON string.
- Ada
- Ali
[
"Ada",
"Ali"
]
yes
"yes"
YAML is turned into a JavaScript value before JSON is written. JSON.stringify then prints that value. This is not JSON.parse. The JSON shows the number and key order JavaScript kept.
A trailing .0 is not kept in the JSON.
Input
small: 1.0
big: 9007199254740993
Output
{
"small": 1,
"big": 9007199254740992
}
Integers outside ±9007199254740991 can change. 9007199254740993 is not preserved, as in the example above.
YAML -0 is written as JSON 0.
Input
value: -0
Output
{
"value": 0
}
Keys that look like array indexes are written in numeric order, then the remaining keys. The names are not renamed. They appear as JSON strings.
Input
10: ten
2: two
name: Ada
1: one
Output
{
"1": "one",
"2": "two",
"10": "ten",
"name": "Ada"
}
.inf and .nan are rejected. The status line is This YAML cannot be converted to JSON. A value is not a finite JSON number.
A broken mapping, a bad indent, or other syntax the parser rejects stays in the editor. The status line starts with Invalid YAML: and then includes the parser message. The preview is cleared.
YAML indentation must use spaces. The second line below is indented with a tab. Status: Invalid YAML: Tabs are not allowed as indentation at line 2, column 1:
name: Ada
city: Quetta
Some odd indents do not fail. They convert to a different value than the layout suggests. This input becomes one list item, not a nested list.
tags:
- yaml
- json
{
"tags": [
"yaml - json"
]
}
An empty editor, whitespace-only text, or a comment with no document shows Paste YAML or open a .yaml or .yml file first. YAML null and ~ are values, and those become JSON null.
A file whose size is 0 is not read. Status: This file is empty. Choose a YAML file with content. The editor and preview are left as they were.
Two documents separated by --- are rejected. A single --- at the start of one document is allowed. Status: Only one YAML document can be converted.
a: 1
---
b: 2
Status: YAML mapping keys must be unique.
role: reader
role: admin
Status: This YAML cannot be converted to JSON. Merge keys are not expanded.
a: 1
<<: { b: 2 }
Status: This YAML cannot be converted to JSON. An unsupported tag was found.
value: !custom foo
Status: This YAML cannot be converted to JSON. Binary data is not supported.
data: !!binary aGVsbG8=
Status: This YAML cannot be converted to JSON. A circular alias was found.
&a
- *a
Status: This YAML cannot be converted to JSON. A value is not a finite JSON number.
A YAML file larger than 5 MiB is rejected before it is read. Status: This file is larger than 5 MiB and was not read.
Pasted YAML longer than 5,000,000 characters is not converted. Status: This YAML is longer than 5,000,000 characters and was not converted. The editor is left as it was, and the preview is cleared.
Editing the YAML clears the JSON so the preview cannot stay out of date. Convert to JSON writes a new preview from the current editor. Copy JSON and Download JSON use that preview. They do not convert again.
No. Copy JSON copies the JSON already in the preview. Download JSON saves that same text as converted-data.json. If the preview is empty, Copy JSON shows Convert YAML to JSON before copying. Download JSON shows Convert YAML to JSON before downloading.
This converter uses YAML 1.2. An unquoted yes, no, on, or off is text. true and false are booleans. The JSON to YAML converter quotes "yes" when writing YAML, which is the other direction.
Yes. Open YAML File accepts .yaml and .yml. Both are read as YAML text. The downloaded file is converted-data.json.
Use the JSON to YAML converter when you already have JSON and need YAML, the JSON Beautifier to format JSON, or the JSON Viewer to inspect the tree.