YAML to JSON converter
Paste YAML or open a .yml file. The JSON updates as you type, and the report under it says what JSON could not keep: comments, aliases, and values that a YAML 1.1 parser would read differently.
What happens to each YAML feature
JSON cannot hold everything YAML can, so the report says each time something had to be dropped or changed.
| In the YAML | In the JSON |
|---|---|
Comments # … | Removed and counted. The YAML 1.2.2 specification says comments are a presentation detail with no effect on the data, and JSON has no comment syntax. Which lines a # really comments out. |
Anchors &name and aliases *name | Each alias becomes a full copy. The yaml library’s alias limit is raised from its default of 100 to 10,000; past that the conversion stops with an error, so a “billion laughs” file cannot freeze the tab. Anchors and merge keys, tested. |
Merge keys <<: *defaults | Applied: the merged keys are inserted unless the mapping already has them, as the merge key type defines. |
Several documents split by --- | A JSON array with one item per document, or JSON Lines. Empty documents, such as a trailing ---, are skipped. |
| Long integers and decimals | Written with the digits in the file: 12345678901234567890 stays exact and 1.10 stays 1.10, instead of passing through a JavaScript number. |
.inf and .nan | Written as null, because JSON has no infinity or NaN, and listed in the report. |
Custom tags such as !Ref | The tag is dropped and the value kept: !Ref MyBucket becomes "MyBucket". The report counts them. |
| A key written twice | An error with its line number, instead of silently keeping one of the values. |
YAML 1.1 and 1.2 read the same file differently
The YAML 1.2 core schema treats only true and false (in three capitalisations) as booleans, writes octal as 0o755, and has no dates or base-60 numbers. The older YAML 1.1 types also read yes, no, on, off, y and n as booleans, a leading zero as octal and numbers with colons as base 60 (int type), and dates as timestamps.
Python’s PyYAML calls itself a complete YAML 1.1 parser, so the same file can give different data in a Python script and in a YAML 1.2 tool. Every file is therefore parsed both ways, and each value whose reading differs is listed with its line. These are the five plain values in the example:
| YAML | YAML 1.2 (default output) | PyYAML 6.0.2 safe_load |
|---|---|---|
country: NO | "NO" | False |
enabled: yes | "yes" | True |
file_mode: 0755 | 755 | 493 |
ports: 22:22 | "22:22" | 1342 |
released: 2026-11-08 | "2026-11-08" | datetime.date(2026, 11, 8) |
The right-hand column is what PyYAML 6.0.2 returned when we loaded the example on 8 November 2026. Choose Read as YAML 1.1 to get that reading as JSON (dates become ISO 8601 text). It follows PyYAML in one detail: the bool type also lists the single letters y and n, but PyYAML keeps them as strings, and so does this mode. To make every parser agree, quote the value in the YAML file: enabled: "yes". The YAML vs JSON guide runs 26 such values through YAML 1.2, YAML 1.1 and PyYAML.
Errors point at the line
When the YAML does not parse, nothing is written to the JSON side. The message gives the line and column, shows the lines just before it with a caret under the position, and Go to line selects that line in the editor. A missing ] in b: [1, 2 is reported at the start of the next line, because that is where the parser finds out the list never closed.
Real files: Kubernetes and Docker Compose
Kubernetes manifests for the API
The Kubernetes documentation says an API request must include the object as JSON in the request body, and that manifests are YAML by convention (JSON also works); kubectl converts them for you. To call the API yourself, convert the manifest here:
apiVersion: v1
kind: ConfigMap
metadata:
name: app-flags
data:
DEBUG: "false" # ConfigMap values are strings
RETRIES: "3"{
"apiVersion": "v1",
"kind": "ConfigMap",
"metadata": {
"name": "app-flags"
},
"data": {
"DEBUG": "false",
"RETRIES": "3"
}
}The comment is dropped and the quoted values stay strings. A file holding several manifests separated by --- becomes a JSON array, one object per manifest; send them to the API one at a time.
Docker Compose: extension fields and anchors
Compose files often share settings through an x- extension field with an anchor and a << merge key. Docker’s reference says Compose ignores any field that starts with x-, that it follows the YAML merge type, and that anchors are resolved before variable interpolation.
x-env: &env
environment:
- CONFIG_KEY
- EXAMPLE_KEY
services:
first:
<<: *env
image: my-image:latest
second:
<<: *env
image: another-image:latest
environment:
- ONLY_SECOND
proxy:
image: nginx:1.27
environment:
https_proxy: ${HTTPS_PROXY}{
"x-env": {
"environment": [
"CONFIG_KEY",
"EXAMPLE_KEY"
]
},
"services": {
"first": {
"environment": [
"CONFIG_KEY",
"EXAMPLE_KEY"
],
"image": "my-image:latest"
},
"second": {
"environment": [
"ONLY_SECOND"
],
"image": "another-image:latest"
},
"proxy": {
"image": "nginx:1.27",
"environment": {
"https_proxy": "${HTTPS_PROXY}"
}
}
}
}In the JSON, first gets the merged environment list, while second’s own environment replaces it completely: as Docker notes, YAML merge only applies to mappings, not to sequences. The x-env block is still there as an ordinary key, and ${HTTPS_PROXY} is kept as written, because a converter does not interpolate variables.
Nothing leaves the browser
The YAML is parsed in this tab with the open-source yaml library, loaded from velkaro.cc itself. There is no upload and no conversion request to a server. Your text is not saved; JSON → YAML passes the result to the other converter through this tab’s session storage and deletes it there as soon as that page reads it. Download saves a .json file (.jsonl for JSON Lines); the JSON to YAML converter goes the other way.
To compare two YAML files, convert each one and paste both into the JSON diff: key order and formatting no longer get in the way, and every changed value is listed by path.
Questions
Are large numbers kept exactly?
Yes. A number such as 12345678901234567890 is written with the same digits. Converters that go through JavaScript numbers round it to 12345678901234567000.
Why does on: become "true" in YAML 1.1 mode?
YAML 1.1 reads an unquoted on, off, yes or no as a boolean even when it is a key, so PyYAML loads on: push as {True: 'push'}. GitHub Actions workflows name their triggers under an on: key, so a workflow file loaded with PyYAML has True where you expect on. Quote the key ("on":) if a YAML 1.1 parser will read the file.
Can I convert JSON Lines back to a multi-document YAML file?
Not in one step: JSON to YAML reads one JSON value. Choose JSON array under Several documents, then turn on One document per array item in the JSON to YAML converter to get the --- separated file back.