JSONToonPro
JSON tool

YAML to JSON Converter

Convert YAML to JSON online instantly. Paste any YAML file, including Kubernetes manifests and Docker Compose configs, and get clean JSON with nested structures and lists preserved. Everything runs 100% client-side in your browser, so your config data never leaves your device.

100% client sideInstant resultNo data sent
34 nodes
Input/ YAML
295 chars20 lines
Output/ JSON
432 chars28 lines

Why Convert YAML to JSON

YAML is written by people. JSON is consumed by programs. Almost every reason to convert in this direction comes down to that split.

  • HTTP APIs overwhelmingly speak JSON. If your configuration lives in YAML but has to be posted to an endpoint, it has to be converted first.
  • JavaScript parses JSON natively and at speed. Loading YAML in a browser means shipping a parser library that is considerably larger than the config it reads.
  • JSON is unambiguous. There is one way to write a mapping and one way to write a list, so there is nothing to disagree about and no implicit typing to trip over.
  • Tooling is broader. Query languages, diff tools, schema validators, and log processors all assume JSON as a lowest common denominator.
  • Machine generated output should not be YAML. If nobody is going to read it, the readability advantage buys you nothing and the parsing cost is real.

Side by Side Example

A continuous integration workflow, converted to JSON. Notice what does not survive.

YAML input

# Nightly build pipeline
name: nightly
on:
schedule:
- cron: "0 2 * * *"
jobs:
build:
runs-on: ubuntu-latest # cheapest runner
steps:
- uses: actions/checkout@v4
- run: |
npm ci
npm test

JSON output

{
"name": "nightly",
"on": {
"schedule": [
{ "cron": "0 2 * * *" }
]
},
"jobs": {
"build": {
"runs-on": "ubuntu-latest",
"steps": [
{ "uses": "actions/checkout@v4" },
{ "run": "npm ci\nnpm test\n" }
]
}
}
}

Both comments are gone without a trace. The block scalar has been resolved into a single string with real newline escapes. The cron expression stayed a string because it was quoted in the source, which is exactly why it was quoted.

What YAML Features Cannot Survive

YAML featureFate in JSONPractical consequence
CommentsDropped entirelyRound tripping YAML through JSON destroys documentation
Anchors and aliasesExpanded into duplicated dataFile size grows, and the shared identity is lost
Merge keysResolved into literal keysOverrides are baked in and no longer traceable
Multi-document filesCannot be one JSON valueEmit a JSON array or separate files
Non-string keysIllegal in JSONKeys such as 1 or true are coerced to strings
Complex keysNo equivalentA mapping used as a key has to be restructured
Block scalar styleCollapsed to one stringThe pipe and fold distinction disappears once parsed
Explicit tagsIgnoredCustom types resolve to plain maps or strings
Trailing formatting and orderingNot guaranteedKey order preservation depends on the serialiser

Anchors expand, they do not link

One anchor used three times

defaults: &d { retries: 3, timeout: 30 }
a: *d
b: *d
 
becomes
 
{ "defaults": { "retries": 3, "timeout": 30 },
"a": { "retries": 3, "timeout": 30 },
"b": { "retries": 3, "timeout": 30 } }

The JSON is correct and the values are right, but the intent is gone. Change the retry count later and you now have three places to edit instead of one. This is why the YAML file should stay the source of truth and the JSON should be treated as a build artefact.

Multiple documents in one file

A line consisting of three hyphens starts a new document, and Kubernetes manifests use this constantly to put several resources in one file. JSON has no document separator, so a three document YAML file becomes either a JSON array of three objects or three separate files. Choose deliberately, because a consumer expecting a single object will fail on an array.

Type Coercion Differences

YAML resolves untagged scalars using pattern rules. JSON has explicit syntax and no inference at all. The conversion therefore locks in whatever the YAML parser decided, and the decision is invisible in the output.

YAML sourceParsed valueJSON output
version: 1.20Float1.2
version: "1.20"String"1.20"
enabled: yesBoolean under 1.1true
code: NOBoolean false under 1.1false
zip: 01234Octal or string, parser dependent668 or "01234"
value: ~Nullnull
blank:Nullnull
big: 12345678901234567890Integer beyond safe rangePrecision loss in JavaScript

YAML 1.1 Versus 1.2

The boolean rules changed between versions and most parsers did not follow. YAML 1.1 treats y, yes, on, true, n, no, off, and false as booleans in a range of casings. YAML 1.2 narrowed this dramatically, with the core schema recognising only true and false.

The catch is that many popular libraries still implement 1.1 semantics by default even though 1.2 was published in 2009. So the same file can convert differently depending on which language and which library you run it through, which is a genuinely unpleasant class of bug when a deployment pipeline and a local script disagree.

The defence is simple and costs nothing: quote any scalar whose string identity matters. Country codes, version numbers, times, zero padded ids, and single letter flags should all be quoted in the source. Then no parser has a decision to make.

Strict JSON is usually a stepping stone. Head to the full converter collection for JSON to YAML to return to a human friendly config, JSON Schema to validate the structure you just produced, and JSON to TypeScript to type it in application code.

Frequently asked questions

4 answers
YAML is great for human-edited config files, but most APIs, JavaScript runtimes, and databases expect JSON. Converting YAML to JSON lets you feed a config file to a REST endpoint, load it with JSON.parse, or validate it against a JSON Schema. JSON parsing is also stricter and more predictable, so converting is a quick way to check exactly what data structure your YAML actually describes.

More JSON Tools

About the YAML to JSON Converter

YAML dominates DevOps configuration: Kubernetes manifests, Docker Compose files, CI pipelines, and Helm values are all written in it. But when that data needs to reach an API, a JavaScript application, or a JSON Schema validator, you need JSON. This YAML to JSON converter handles the translation instantly: nested mappings become objects, sequences become arrays, anchors and aliases are expanded, and multi-line strings are flattened into standard JSON strings. It is also a quick sanity check for YAML's notorious type quirks, since the JSON output shows exactly whether a value parsed as a string, number, or boolean. Free, instant, and entirely in your browser.