JSON to YAML
This free JSON to YAML converter turns JSON into YAML entirely in your browser. Paste your JSON or upload a .json file, choose how strict the quoting should be, read the output, and download a .yaml file. Nothing leaves your device, and there is no sign-up.
Converting JSON to YAML looks like a formatting job, but the one thing that actually breaks data is quoting. Write yes unquoted and a YAML 1.1 reader hands you back a boolean. Write 007 unquoted and you get the number 7. Write 2001-12-14 unquoted and a YAML 1.1 reader hands you back a date instead of a string. None of those round-trip. This page decides quoting against a named resolver — YAML 1.2 core schema or YAML 1.1, your choice — and then lists every value it quoted together with the rule that forced it.
How to use this JSON to YAML converter
- Paste your JSON into the box, or upload a
.jsonor.txtfile. - Pick the Indent width — 2 or 4 spaces per level.
- Pick Read back as: YAML 1.2 (core schema) or YAML 1.1. This is the version whose rules decide whether a value is ambiguous. If you do not know which one will read your file, choose YAML 1.1 — it treats more values as ambiguous, so it quotes more and is the safer default.
- Choose Null as (
null,~, or an empty value) and Line breaks (literal block scalar, or escaped\ninside double quotes). - Click Convert to YAML, open Why these values are quoted to check the decisions, then Download .yaml.
What this tool supports
Quoting: when a value must be quoted
A plain (unquoted) YAML scalar is not always a string. Every YAML processor matches it against a list of regular expressions first, and whatever matches wins. Two rules follow from that, and this page applies both:
- Ambiguity. If a string would be resolved to
null,bool,int,floator (under YAML 1.1)timestamp, it is quoted, because reading it back would not give you the string you started with. - Structure. If a string cannot be written as a plain scalar at all — it starts with an indicator character such as
#,[,-followed by a space, or!; or it contains": "or" #"; or it has leading or trailing whitespace, which plain scalars drop — it is quoted too.
The resolvers are transcribed from the specifications: the YAML 1.2.2 specification, section 10.3.2 (Core Schema, Tag Resolution), and the YAML 1.1 type definitions for bool, int, float, null and timestamp. The structural rules come from the plain-scalar productions of the YAML 1.2.2 specification. Here is what that means for real values:
| Value in your JSON | Unquoted, read back by YAML 1.2 (core schema) | Unquoted, read back by YAML 1.1 | What this page writes |
|---|---|---|---|
"true", "false", "True", "FALSE" | boolean | boolean | 'true' |
"yes", "no", "on", "off", "y", "n" | string — safe unquoted | boolean | 'yes' under 1.1, plain yes under 1.2 |
"null", "~" | null | null | 'null' |
"" (empty string) | null — an empty plain scalar is null | null | "" |
"007" | integer 7 | integer 7 — a leading 0 means octal | '007' |
"0x1F" | integer 31 | integer 31 | '0x1F' |
"1_000" | string — safe unquoted | integer 1000 — _ is ignored | '1_000' under 1.1 |
"190:20:30" | string — safe unquoted | integer 685230 — base 60 | '190:20:30' under 1.1 |
"2001-12-14" | string — the core schema has no timestamp type | timestamp | '2001-12-14' under 1.1 |
"1.0" | float 1.0 | float 1.0 | '1.0' |
".inf", ".nan" | float | float | '.inf' |
"#9" | cannot be a plain scalar — starts with # | same | '#9' |
"a: b" | split into key a and value b | same | 'a: b' |
"- item" | read as a sequence entry | same | '- item' |
" padded " | leading and trailing spaces are dropped | same | ' padded ' |
Keys are checked with the same rules. A JSON key such as "true", "007" or "yes" is quoted as well, because an unquoted key is resolved by the very same list of regular expressions.
Indentation
Two or four spaces per level. Sequences are written with the classic - prefix and their contents indented one level, so a list of objects comes out as - id: 1 followed by the remaining keys aligned under id.
Nulls, empty objects and empty arrays
- Null can be written as
null, as~, or as an empty value (key:with nothing after the colon). All three read back as null; pick the one your project's style expects. - Empty object becomes
{}and empty array becomes[], written inline on the same line as the key. Both are flow collections, and both read back as an empty map and an empty sequence rather than as null.
Multi-line strings
By default a string containing line breaks is written as a literal block scalar: the key is followed by |, |- or |+, and the text follows on indented lines. |- means no trailing newline, | means one trailing newline, and |+ means every trailing newline is kept — the page picks the header from your actual string so the value round-trips. Switch Line breaks to Escaped and the same string is written on one line with \n inside double quotes instead.
A block scalar cannot preserve trailing spaces on a line or leading indentation on its first line. When your string has either, the page falls back to the escaped form and says so in the explanation list, instead of silently losing those characters.
Numbers and key order
- Numbers keep their original text.
1.0stays1.0and is not rewritten to1. - JSON writes exponents as
1e5, but the YAML 1.2 core schema requires a signed exponent and YAML 1.1 additionally requires a.in a float. Left alone,1e5would come back as the string"1e5". This page rewrites it to1.0e+5so it still reads back as a number, and reports the rewrite. - Key order is preserved exactly. The JSON is read by a parser written for this page rather than by
JSON.parse, because JavaScript objects reorder keys that look like array indexes —{"2":…, "1":…}would otherwise come out swapped.
Privacy
Uploaded files are read with the browser's own file reader and never leave your device. There is no upload endpoint on this page, no account, and no stored history. You can disconnect from the internet after the page loads and it will still work.
What this tool does not do
- Comments are not preserved, because JSON has no comments. A
//or/* */inside your input is not valid JSON, so this page rejects it rather than pretending to carry anything over into the YAML output. If you need comments in the result, add them after converting. - Duplicate keys collapse. JSON does not define what
{"a":1,"a":2}means; this page keeps the last value, keeps the first key's position, and tells you how many duplicates it collapsed. - Anchors, aliases, tags and merge keys are never produced. Output is plain block YAML only.
- One input, one output. No batch conversion, no login, no history.
FAQ
Is this JSON to YAML converter free?
Yes. It is free with no login and no usage limit, and all processing stays in your browser. For the other directions see the JSON to CSV converter, the JSON to Excel converter, the JSON to XML converter and the CSV to JSON converter.
Do I have to upload my JSON file?
No. The file is read locally with the browser's file API and converted in the page. Nothing is uploaded, logged or stored, and you can go offline after the page loads.
What is the difference between .yaml and .yml?
They are the same format with two different file extensions. This tool downloads a .yaml file with a timestamp in its name; renaming it to .yml changes nothing about the contents, and every YAML reader accepts both.
Why is my string quoted when I did not ask for it?
Because writing it unquoted would change its value, or because it cannot be written as a plain scalar at all. Open Why these values are quoted under the output: each row gives the value, its position in your document, and the exact rule — for example "Ambiguous: an unquoted value reads back as bool under YAML 1.1".
Why is "yes" quoted under one setting but not the other?
Because the two versions disagree. The YAML 1.1 bool type resolves y, yes, on, no, off and their capitalised forms to booleans; the YAML 1.2 core schema resolves only true, True, TRUE, false, False and FALSE. Set Read back as to the version that will actually parse your file, and the quoting follows it.
Which version should I choose if I am not sure?
Choose YAML 1.1. It resolves a larger set of plain scalars to non-string types — booleans, base-60 and underscore integers, timestamps — so this page quotes more values under it. More quotes are always safe: a quoted scalar is a string in every version. Fewer quotes are only safe if you know the reader.
Does it keep the order of my keys?
Yes, exactly as written, including keys that look like numbers. The JSON is parsed by a purpose-built parser rather than by JSON.parse, whose objects reorder integer-like keys.
How are multi-line strings written?
As literal block scalars by default: | with the text on the following indented lines, and |- or |+ depending on whether your string ends with a newline. Switch Line breaks to Escaped for a single-line \n form instead. If a block scalar cannot preserve your string's trailing spaces, the page uses the escaped form and tells you.
Can it keep my comments?
No. JSON has no comment syntax, so there is nothing in the input to keep. Comments are valid in YAML output, but they have to be added by you after converting.
Is there a file size limit?
There is no imposed limit — conversion runs in your browser's memory, so very large files depend on your device. The JSON to CSV converter page covers how this applies to large inputs.
My JSON was rejected. Why?
The error names the line and column. The usual causes are a trailing comma, a single-quoted string, an unquoted key, or a comment — none of which are legal JSON.