What is a YAML to JSON converter?
YAML is the plain-text format that config files are written in — Docker Compose files, Kubernetes manifests, CI pipelines, and app settings. It uses indentation instead of brackets, which makes it easy to read but hard for programs to consume. JSON is the format programs prefer. This converter turns the first into the second.
The default text on this page shows the idea clearly. Three lines of YAML — name: Ada, age: 36, city: London — become the JSON object {"name":"Ada","age":36,"city":"London"}. Same data, different shape: the YAML is written for humans, and the JSON is written for machines.
The conversion also types the values. The YAML number 36 becomes the JSON number 36, not the string "36". The word true becomes the boolean true, and an empty value becomes null. That typing is what makes the JSON useful in code instead of a pile of strings.
Everything runs in your browser. Your data never leaves your device, nothing is uploaded or stored, and there is no account to create. You can convert sensitive config — keys, passwords, private settings — without worrying about who else sees it.
How YAML becomes JSON
The conversion is done by js-yaml, a well-known open-source YAML parser, version 4.1.0, released under the MIT licence. The library file is vendored on this site at /vendor/js-yaml.min.js, so the page loads it from sortrun.com itself — no outside service is involved, and the conversion works offline once the page has loaded.
The page calls js-yaml's load function on your text, which reads the YAML and builds a JavaScript value: an object for a mapping, an array for a list, a string, number, boolean, or null for a plain value. That value is then printed as JSON with two-space indentation, which is the clean output in the box below.
There is also a built-in fallback parser for the common subset of YAML: mappings, lists, nested blocks, quoted strings, numbers, booleans, nulls, and comments. It runs only if the library is unavailable, and it is labelled honestly as a subset — it does not cover flow collections, anchors, or multi-line scalars, and nested lists must be indented deeper than their key.
The two paths agree on ordinary YAML. The examples on this page — a flat mapping, a list of mappings, a nested mapping — produce identical JSON from the library and from the fallback, which was checked directly. If your YAML uses an advanced feature, the library path handles it; the fallback reports an error rather than guessing.
The YAML rules that matter
Indentation is structure. In YAML, two spaces of indent mean 'inside the thing above'. The block server: followed by host: localhost indented two spaces means host belongs to server. Change the indent and you change the data — which is why consistent indentation matters more in YAML than in any other format.
Tabs are forbidden. YAML does not allow tab characters for indentation, and both the library and the fallback refuse a document that uses them. If your editor inserts tabs, switch it to spaces — two spaces per level is the common choice, and it is what the examples on this page use.
Types are guessed from the text. An unquoted 36 is a number, true is a boolean, and an empty value is null. If a value must stay a string, quote it: version: "1.2" stays a string, while version: 1.2 would become a number. Quoting is how you tell YAML not to guess.
Comments start with a hash. A # after a space begins a comment that runs to the end of the line, and the converter ignores it. A # inside a quoted string is not a comment — "C#" stays exactly as written. That distinction matters when values contain hashes, which happens more often than people expect.
A worked example: config, list, and nesting
Start with the default text: three lines, name: Ada, age: 36, city: London. The converter produces {"name":"Ada","age":36,"city":"London"} — 3 top-level keys, 0 list items. Flat YAML in, flat JSON out, with the age correctly typed as a number.
Now a list of mappings: two items, each with a name and an age. The result is [{"name":"Ada","age":36},{"name":"Grace","age":40}] — 0 top-level keys, 2 list items. Each dash starts an item, and the indented lines under it belong to that item. Lists of mappings are the shape of most real config: users, servers, jobs, steps.
Try nesting: server: on one line, then host: localhost and port: 8080 indented under it, then debug: true back at the top level. The result is {"server":{"host":"localhost","port":8080},"debug":true} — 2 top-level keys. The indent did the work: host and port belong to server, and debug stands on its own.
Finally, try broken YAML: name: Ada followed by a line with no colon. Both the library and the fallback refuse it, and the tool reports invalid YAML instead of producing JSON. There is no honest way to convert a document that does not parse, so the tool refuses and says so plainly.
Who converts YAML to JSON, and why
Developers are the biggest users. Config files are written in YAML because humans read them, but the tools that consume config often want JSON. Converting once, at the boundary, is far easier than teaching every tool to read YAML — and it catches indentation mistakes before they reach production.
DevOps engineers are the second group. Kubernetes manifests, CI pipelines, and infrastructure definitions are all YAML, and debugging them means reading the data as the system sees it. Converting to JSON shows the structure without the indentation, which makes a misplaced key obvious.
Testers are a third group. They build YAML fixtures for tests and need JSON versions to feed into a test harness or an API. Converting by hand is slow and error-prone; pasting the block here and copying the result takes seconds and cannot introduce a typo.
Students are a fourth group. Comparing the same data in YAML and JSON side by side is the fastest way to understand both formats. The converter shows the mapping in action: indentation to nesting, dashes to arrays, plain text to typed values — and the differences between the two formats become obvious.
YAML to JSON vs JSON formatter
A YAML converter and a JSON formatter solve different problems. A JSON formatter takes JSON that already exists and prints it neatly. This converter takes YAML — a different format entirely — and produces JSON from it. If your input is YAML, the formatter cannot help you; if your input is JSON, the converter has nothing to do.
The natural workflow is convert first, then format. Convert the YAML to JSON here, and the output is already printed with two-space indentation, so it is readable as it stands. If you need it minified for an API, a text formatter cleans up plain text, though the JSON itself is already clean.
Writing YAML well is a separate skill from converting it. A markdown editor shows how another plain-text format turns into a rendered result, and a base64 encoder decoder moves the converted JSON safely inside a URL or a header. Convert first, then move it — in that order.
One honest limit is worth repeating: the built-in fallback parser covers the common subset only. Flow collections like {a: 1}, anchors, and multi-line scalars need the full library, which is what the page uses. If the fallback ever reports an error on YAML that looks fine, the library path is the one that decides.
Common YAML mistakes
The most common mistake is using tabs for indentation. YAML forbids tabs, and both the library and the fallback refuse a document that uses them. If your editor inserts tabs, switch it to spaces. Two spaces per level is the standard, and it is what every example on this page uses.
Second: inconsistent indentation. A block indented two spaces in one place and four in another is a different structure, not the same structure written differently. Pick one indent size — two spaces — and use it everywhere. Mixing sizes is how keys end up nested under the wrong parent.
Third: unquoted values that YAML reads as types. version: 1.2 becomes a number, on: yes becomes a boolean true in some parsers, and a date like 2026-11-15 becomes a date object. If a value must stay a string, quote it. Quoting is how you tell YAML not to guess.
Fourth: a colon inside an unquoted value. A line like note: see: this breaks, because the second colon confuses the parser. Quote the value — note: "see: this" — and the colon stays part of the text. Colons are safe inside quotes and dangerous outside them.
How to use this YAML to JSON converter
Using this converter is simple. Paste your YAML into the box, or type it directly. The JSON appears instantly in the box below, printed with two-space indentation, with the key count and list-item count shown above it. There is no button to press and no form to submit.
To use the result, select the text in the output box and copy it. To convert another block, select all, delete, and paste the new one — the counts reset instantly. If the YAML is invalid, the output box shows the error message instead; read it, fix the line it points to, and paste again.
Everything runs in your browser. No sign-up, no account, no data sent anywhere — your YAML never leaves your device. It works offline once the page has loaded, because the js-yaml library is vendored on this site rather than fetched from a CDN.
Try it with something real before you need it: paste a config file you use — a Compose file, a CI step, an app setting — and read the JSON it becomes. Once you have used it twice, the mapping — indentation to nesting, dashes to arrays — becomes second nature.