How the conversion works
Click Convert (or press Ctrl + Enter). The YAML is parsed with js-yaml 4.1.0 into ordinary JavaScript values, and those values are written out with JSON.stringify at the indent you selected: 2 spaces, 4 spaces, or Minify. There is no custom mapping layer in between, so the JSON shows exactly how a JavaScript program using js-yaml would see your file. That makes this tool useful for more than conversion: it answers the question "what type did YAML give this value?"
Example: a GitHub Actions workflow
name: CI
on:
push:
branches: [main]
pull_request:
env:
NODE_VERSION: "20"
RETRIES: 3
defaults: &job
runs-on: ubuntu-latest
timeout-minutes: 10
jobs:
test:
<<: *job
steps:
- uses: actions/checkout@v4
- run: npm ci && npm test # unit tests
env:
CI: true
converts, with Indent: 2, to:
{
"name": "CI",
"on": {
"push": {
"branches": [
"main"
]
},
"pull_request": null
},
"env": {
"NODE_VERSION": "20",
"RETRIES": 3
},
"defaults": {
"runs-on": "ubuntu-latest",
"timeout-minutes": 10
},
"jobs": {
"test": {
"runs-on": "ubuntu-latest",
"timeout-minutes": 10,
"steps": [
{
"uses": "actions/checkout@v4"
},
{
"run": "npm ci && npm test",
"env": {
"CI": true
}
}
]
}
}
}
Several things happened that are worth knowing:
on stayed a string key. Under YAML 1.2 it is not a boolean.
pull_request: with no value became null.
"20" stayed a string because it was quoted, while RETRIES: 3 became a number and CI: true a boolean.
- The
<<: *job merge key was resolved: the two keys from defaults were copied into test. The anchor and alias themselves do not exist in JSON.
- The comment after
npm test was dropped.
How YAML values map to JSON
| YAML input | JSON output | Note |
key: or ~ or null | null | Empty values are null, not "" |
'42' or !!str 42 | "42" | Quoting or a tag forces a string |
0x1F, 0o17, 1e3 | 31, 15, 1000 | Hex, octal, and exponent forms become plain numbers |
02134, 3.10 | 2134, 3.1 | Leading and trailing zeros are lost |
2026-09-23 | "2026-09-23T00:00:00.000Z" | Timestamps become ISO strings in UTC |
.inf, .nan | null | JSON has no infinity or NaN |
!!set {a, b} | {"a": null, "b": null} | Sets become objects with null values |
Pitfalls to check in the output
Large integers lose precision
JavaScript numbers are exact only up to 9,007,199,254,740,991. An ID like 12345678901234567890 comes out as 12345678901234567000. Quote long IDs, account numbers, and snowflake IDs in the YAML.
Numeric keys move to the top
Keys that look like non-negative integers, such as 1: or 404:, are always listed first in the JSON, in ascending numeric order, regardless of their position in the YAML. The data is the same, but diffs against the original order will look noisy. Non-string keys are also converted to strings: true: x becomes "true": "x".
Aliases multiply
Each alias is expanded into a full copy of the anchored data. A Compose file that reuses one large x-common block in ten services will produce ten copies in JSON.
Templates are not YAML yet
Helm and Ansible files with unquoted {{ ... }} expressions either fail or are parsed as nested maps with meaningless keys. Render the template first and convert the result.
Limitations
- One document per conversion. Files with multiple
--- documents, such as combined Kubernetes manifests, are rejected.
- A file containing only comments converts to
null.
- Custom tags such as CloudFormation's
!Ref or !Sub are not recognized and cause an "unknown tag" error.
- There are no options for type handling. Values are typed exactly as js-yaml's default schema decides.
When to use a different tool
- If conversion fails, find the problem line with the YAML Validator.
- To convert JSON back into YAML, use JSON to YAML.
- To sort keys or reformat the resulting JSON, use the JSON Formatter.
- To flatten a list of records into a spreadsheet, follow up with JSON to CSV.
Frequently asked questions
Does the converter handle anchors, aliases, and merge keys?
Yes. js-yaml resolves every alias (*name) and merge key (<<: *name) while parsing, so the JSON contains a full copy of the referenced data at each place it is used. JSON has no references, so the output can be noticeably larger than the YAML.
Why did my date turn into a timestamp?
An unquoted value like 2026-09-23 is a YAML timestamp. js-yaml turns it into a JavaScript Date, and JSON.stringify writes that as an ISO string such as "2026-09-23T00:00:00.000Z". Quote the date in the YAML if you want the original text.
Why is "on" not converted to true in my GitHub Actions file?
js-yaml follows YAML 1.2, where only true and false (written in lowercase, capitalized, or all caps) are booleans. Words like on, off, yes, and no stay strings. Parsers that follow YAML 1.1, such as PyYAML, would turn them into booleans, so results can differ between tools.
Can I convert a file with several documents separated by ---?
No. Only one YAML document can be converted at a time. A multi-document file fails with "expected a single document in the stream, but found more". Convert each document separately, or combine them into one list.
Why are my comments missing from the JSON?
JSON has no comment syntax, and YAML comments are not part of the parsed data, so they are always dropped during conversion.
Is anything sent to a server?
No. The YAML is parsed with js-yaml and serialized with JSON.stringify in your browser. Import URL fetches the file directly from your browser.