About this tool
Convert and validate between JSON and YAML while keeping large integers, decimals and exponents exact. Handy for moving between API data and YAML configs for Kubernetes or CI.
Typical uses
- Turn a JSON config into YAML for Kubernetes
- Convert YAML to JSON for a program to read
- Validate the syntax of a YAML file
How to use
Select JSON to YAML or YAML to JSON, then paste the input.
Convert, then copy or download the generated configuration text.
Convert JSON containing 9007199254740993 and 0.12345678901234567891, then convert back to verify the digits without JavaScript floating-point rounding.
Preserves large integers, decimals and exponents. Input 1M / output 2M characters, 120 levels and a 5-second deadline. One YAML 1.2 document with string keys. Rejects duplicates, cycles, merge keys and incompatible types; ordinary references expand and comments are removed.
Supports one YAML 1.2 document and JSON-compatible types. Duplicate keys, circular references, merge keys and custom tags raise errors. Ordinary aliases are expanded and comments are removed. Other programs may still round the output when reading it.
YAML 1.2 versus 1.1: same text, different values
The tool reads and writes YAML 1.2. The 1.2 core schema treats only true and false (also True, TRUE and so on) as booleans. YAML 1.1 also counted yes, no, on, off, y and n as booleans, read numbers with a leading 0 as octal, and allowed underscores and base-60 numbers. Many older programs still parse 1.1, so the same file can yield different data:
| Written in YAML | JSON from this tool | Read under YAML 1.1 rules as | Written by this tool for JSON → YAML |
|---|---|---|---|
| NO | "NO" | boolean false | NO |
| yes | "yes" | boolean true | yes |
| off | "off" | boolean false | off |
| y | "y" | boolean true | y |
| 010 | 10 | number 8 | "010" |
| 1_000 | "1_000" | number 1000 | 1_000 |
| 1:30 | "1:30" | number 90 | 1:30 |
- The first row is the well-known “Norway problem”: the country code NO becomes false under 1.1. In YAML → JSON this tool keeps it as the string "NO".
- Watch the other direction: the unquoted values in the last column (NO, yes, 1_000 and so on) are plain strings in 1.2, so the tool writes them without quotes. If the YAML will be read by a 1.1 parser, add quotes to those values by hand.
- Strings that 1.2 would read as another type, or that contain YAML syntax, are quoted automatically: 010 → "010", 1e3 → "1e3", null → "null", ~ → "~", True → "True", ∅ → "", a: b → "a: b", #x → "#x".
| YAML 1.2 spelling | Converted to JSON |
|---|---|
| 0o10 | 8 |
| 0x1F | 31 |
| +12 | 12 |
| .5 | 0.5 |
| 1e3 | 1e3 |
| TRUE | true |
| Null | null |
| ~ | null |
| 2026-10-23 | "2026-10-23" |
| .inf | Rejected |
| ∅ | null |
A date such as 2026-10-23 is just a string in the 1.2 core schema and comes out as a string. .inf and .nan have no JSON number, so they trigger “Only JSON-compatible YAML 1.2 types are supported. Custom tags, NaN and Infinity are unsupported.”. The last row is a key with nothing after the colon, which gives null.
Large integers and long decimals are not rounded
The browser’s JSON.parse turns numbers into 64-bit floats, silently changing integers above 2^53 and long decimals. This tool copies the number text instead, which is why a successful run says “Converted, preserving number literal precision.”. A JSON → YAML → JSON round trip:
| JSON text | Written in YAML | Back to JSON | Value seen by JSON.parse |
|---|---|---|---|
| 9007199254740993 | 9007199254740993 | 9007199254740993 | 9007199254740992 |
| 12345678901234567890 | 12345678901234567890 | 12345678901234567890 | 12345678901234567000 |
| 0.12345678901234567891 | 0.12345678901234567891 | 0.12345678901234567891 | 0.12345678901234568 |
| 1.10 | 1.10 | 1.10 | 1.1 |
| 1e999 | 1e999 | 1e999 | Infinity |
| -0 | -0 | -0 | 0 |
- The trailing zero in 1.10, the sign of -0 and out-of-range literals such as 1e999 all survive unchanged.
- In YAML → JSON, YAML-only number spellings are rewritten in a form JSON accepts, without changing the value: +000123 → 123, 123. → 123, 0x20000000000001 → 9007199254740993.
- The program that reads the result may still parse numbers as floats and round them. For IDs and other long numbers, the safer fix is to store them as strings in the source data.
Anchors, comments, multiple documents and layout
| YAML input | Result |
|---|---|
| base: &b {host, port} + prod: *b | { "base": { "host": "db", "port": 5432 }, "prod": { "host": "db", "port": 5432 } } |
| <<: *d (merge key) | “JSON object keys must be strings. YAML merge keys are unsupported.” |
| 200: OK (number as key) | “JSON object keys must be strings. YAML merge keys are unsupported.” |
| "200": OK (quoted key) | { "200": "OK", "404": "Not Found" } |
| true: x | “JSON object keys must be strings. YAML merge keys are unsupported.” |
| # comment, b: 1 # trailing comment, a: 2 | { "b": 1, "a": 2 } |
| ---, a: 1, ... | { "a": 1 } |
| a: 1, ---, b: 2 | “Convert one YAML document at a time. Split multiple documents first.” |
| text: | (literal block) and folded: > (folded block) | { "text": "line1\nline2\n", "folded": "a b\n" } |
| Indented with a tab | “Invalid syntax. Check the marked position.” Tabs are not allowed as indentation |
| Tags such as !!binary | “Only JSON-compatible YAML 1.2 types are supported. Custom tags, NaN and Infinity are unsupported.” |
| a: &a [*a] (refers to itself) | “Circular or invalid YAML aliases cannot be converted.” |
| %YAML 1.1 directive | “Only JSON-compatible YAML 1.2 types are supported. Custom tags, NaN and Infinity are unsupported.” |
- Ordinary anchors and aliases are expanded into full copies. Merge keys (<<) are not expanded but rejected, so write the fields out first. A JSON string key "<<" is quoted when converted to YAML, as "<<": 1, so it is not taken for a merge key.
- JSON allows only strings as object keys, so numeric and boolean keys are rejected; quoting them fixes it.
- All comments are lost, but key order is kept (b still comes before a in the table).
- JSON → YAML always uses 2-space indentation, never wraps long strings, and writes strings containing line breaks as a block: s: |- ⏎ ··line1 ⏎ ··line2. Nested arrays look like a: ⏎ ··- 1 ⏎ ··- - 2 ⏎ ····- 3 ⏎ ··- b: null ⏎ e: [] ⏎ o: {} (· is one space); empty arrays and objects are written [] and {}.
- YAML → JSON always uses 2-space indentation with no minify or indent option; run the result through the JSON formatter if you need another layout.
When conversion fails
| Message | Usual cause | Fix |
|---|---|---|
| Invalid syntax. Check the marked position. | Comments, a trailing comma, single quotes or NaN in JSON; tab indentation or an unclosed bracket in YAML | Fix the marked position; JSON input must be strict JSON |
| Duplicate keys must be resolved before conversion. | The same key twice at one level (checked in both directions) | Remove or rename one of them |
| JSON object keys must be strings. YAML merge keys are unsupported. | A YAML key that is a number, boolean or null, or a << merge key | Quote the key; expand merges by hand |
| Only JSON-compatible YAML 1.2 types are supported. Custom tags, NaN and Infinity are unsupported. | Custom tags, !!binary, .inf, .nan or %YAML 1.1 | Use a plain string or number |
| Circular or invalid YAML aliases cannot be converted. | An alias that points to itself or to a parent | Remove the cycle |
| Input nesting or expanded node count is too large. Split it into smaller parts. | More than 120 levels, or over 100,000 nodes after aliases are expanded | Convert it in parts |
| Convert one YAML document at a time. Split multiple documents first. | Several documents separated by --- | Paste one document at a time |
Limits (input characters / output characters / levels / nodes): 1,000,000 / 2,000,000 / 120 / 100,000; a run stops after 5 seconds. “Import UTF-8 file” accepts UTF-8 text only and removes a leading BOM. After changing “Direction” or the input, click “Convert” again.
Sources
Frequently asked questions
Are YAML comments kept?
No. Comments are removed during conversion.
Are anchors and aliases supported?
Ordinary aliases are expanded; merge keys (<<), cycles and duplicate keys are rejected.
Does it support multi-document YAML?
One YAML 1.2 document with string keys per conversion.
Suggest an improvement to this tool
Missing an option, something awkward to use, or a wrong result? Let us know.