YAML to JSON
This free YAML to JSON converter turns YAML into JSON entirely in your browser. Paste your YAML or upload a .yaml or .yml file, choose which YAML version decides the types, read the JSON, and download a .json file. Nothing leaves your device, and there is no sign-up.
The reason this conversion loses data is not formatting — it is that YAML can express things JSON cannot. YAML has comments, dates, anchors and aliases, non-string keys, .inf, .nan, and several documents in one file. JSON has none of those. Most converters drop them silently. This page does the opposite: it types your values against a named resolver — YAML 1.2 core schema or YAML 1.1, your choice — and then lists every value where it had to make a decision, with the reason.
How to use this YAML to JSON converter
- Paste your YAML into the box, or upload a
.yaml,.ymlor.txtfile. - Pick the Indent width — 2 or 4 spaces per level.
- Pick Resolve types as: YAML 1.2 (core schema) or YAML 1.1. This decides what plain values become, not how they look. Under 1.2,
yesis the string"yes"; under 1.1 it is the booleantrue. - If the file has more than one document (separated by
---), choose First document only or As an array. - Choose what
.infand.nanbecome: null (valid JSON, value lost) or string ("Infinity", value kept, no longer a number). - Open What JSON could not keep under the output to read every substitution, then press Download .json.
What this tool supports
Typing: which YAML version decides
A plain value in YAML is not typed by how it looks, it is typed by the resolver of the parser that reads it. That is why the same file produces different JSON in different tools. This page makes you choose the resolver, and the choice changes the result for these values:
| YAML you wrote | Under YAML 1.2 core schema | Under YAML 1.1 |
|---|---|---|
yes / no | "yes" — a string | true / false |
on / off | "on" — a string | true / false |
y / n | "y" — a string | true / false |
007 | 7 — a decimal integer | 7 — an octal integer (same number, different rule) |
019 | 19 — a decimal integer | "019" — a string, because 9 is not an octal digit |
1_000 | "1_000" — a string | 1000 — underscores ignored |
0x1F | 31 | 31 |
190:20:30 | "190:20:30" — a string | 685230 — base-60 integer |
2001-12-14 | "2001-12-14" — a string | string "2001-12-14", reported as a date |
1.0 | 1 — a number | 1 — a number |
~ or empty value | null | null |
If you do not know which one your pipeline uses, choose YAML 1.1 when the file was written for older tooling (PyYAML before 5.1, Ruby, Symfony) and YAML 1.2 when it was written for Go, JavaScript or Kubernetes-flavoured tooling. When in doubt, the report panel tells you exactly which values changed their type.
Things JSON cannot keep
| In your YAML | What this page writes | Why |
|---|---|---|
# comment | dropped, counted in the notes | JSON has no comment syntax |
released: 2001-12-14 | "2001-12-14" | JSON has no date type, so the original text is kept as a string |
ratio: .inf | null, or "Infinity" if you pick as string | JSON has no Infinity |
ratio: .nan | null, or "NaN" if you pick as string | JSON has no NaN |
1: one (integer key) | "1": "one" | JSON object keys are always strings |
true: yes (boolean key) | "true": true | JSON object keys are always strings |
? [a, b] style complex keys | the key rendered as a string | JSON object keys are always strings |
big: 12345678901234567890 | "12345678901234567890" | bigger than JSON numbers hold exactly (2^53), kept as text so no digit is lost |
&a value then *a | the alias is replaced by a copy of the value | JSON has no references |
<<: *base | the anchor's entries copied into the mapping | merge keys are a YAML feature |
--- between documents | first document, or an array of all of them | JSON is a single document unless you wrap it |
Multi-line strings
Block scalars are read the way YAML defines them. A literal block (|) keeps every line break; |- strips the trailing newline, |+ keeps them all. A folded block (>) joins lines with spaces and turns blank lines into real newlines. Whatever the block produces becomes one JSON string, with \n escaped.
Nulls, empty values, empty collections
A key with no value, ~, and null all become JSON null. An empty flow collection {} becomes {} and [] becomes [].
Key order
Keys come out in the order they appear in your YAML. Nothing is sorted or reordered, and duplicate keys keep the position of the first one while the later value wins — the report says so.
Privacy and limits
Parsing happens in your browser with JavaScript only. No file is uploaded, nothing is stored after you close the tab, and there is no account. Because everything runs in your browser's memory, very large files (tens of MB) depend on your device; typical configuration files and API dumps convert instantly.
What this tool does not do
- It cannot keep comments. JSON has no comment syntax, so comments are dropped and counted. It does not try to smuggle them in as fake keys.
- It does not support custom tags such as
!!binary,!MyClassor language-specific tags. The common ones —!!str,!!int,!!float,!!bool,!!null— are honoured; an unknown tag falls back to normal type resolution. - It does not merge several files. One conversion at a time, no batch mode.
- It does not keep references. Aliases are expanded into copies, so a value that appears once in YAML may appear several times in JSON.
- It does not fix broken YAML silently. Tabs used for indentation, an unterminated quote, an unknown alias and a mapping key without its colon are all reported with the line number instead of being guessed at.
Frequently asked questions
Is this YAML to JSON converter free?
Yes. No account, no sign-up, no conversion limit, and no upload — the work happens in your browser.
Is my YAML uploaded anywhere?
No. The file you pick is read with the browser's own File API and parsed in the page. There is no request that carries your data.
Can I convert a .yml file, not just .yaml?
Yes. The file picker accepts .yaml, .yml and .txt, and pasting works for any of them. The two extensions mean the same format.
Why did my yes become true?
Because the resolver is set to YAML 1.1, where yes, no, on, off, y and n are booleans. Switch Resolve types as to YAML 1.2 (core schema) and the same file gives you the string "yes".
Which version should I pick if I do not know?
Pick YAML 1.1 if the file is consumed by older tooling that expects booleans from yes/no and integers from 007. Pick YAML 1.2 for modern stacks. Either way the report under the output names every value whose type depends on that choice.
Where did my comments go?
JSON has no comment syntax, so they are dropped. The note under the output tells you how many were removed. If you need to keep them, keep the YAML as the source of truth.
My file has several documents separated by ---. What happens?
By default only the first document is converted. Switch Multiple documents to As an array and you get a JSON array with one element per document.
Why is my date a string?
JSON has no date type, so a YAML timestamp becomes a string holding the original text. Anything reading the JSON has to parse it back into a date on purpose.
Why did my key 1 become "1"?
JSON object keys are always strings, so a YAML integer, boolean or null key is written as text. The report lists every key this happened to.
Do anchors and aliases work?
Yes. An alias is replaced by a copy of the value its anchor points at, and merge keys (<<: *base) copy the anchor's entries into the mapping. A self-referencing alias is reported as an error instead of hanging the page.
Is there a file size limit?
There is no imposed limit. Parsing happens in your browser's memory, so extremely large inputs (tens of MB) may be slow depending on your device. Configuration files and API exports convert instantly.
Why does it say my YAML is invalid?
The error names the line. The usual causes are a tab used for indentation, an unterminated quote, a mapping key without its colon, or an alias whose anchor does not exist. Fix the named line and it converts.
Can I go the other way?
Yes — use the JSON to YAML converter for the reverse direction. If the next stop is a spreadsheet or an API payload, the JSON to Excel and JSON to XML pages take it from there, and CSV to JSON handles tabular input.