Our methodology
The exact formulas, letter tables and rules our cipher tools use. Every result on this site comes from the methods on this page.
Where the work happens
Every tool runs in your browser in plain JavaScript. Your text never goes to a server, so results appear as you type and work offline once the page loads.
20,000 characters
The text box limit. Longer text is cut off, and the tool tells you.
6,000 characters
The sample the Caesar shift finder scores, so long messages rank instantly.
0 uploads
Files you open are read on your device and go nowhere.
Letters as numbers
Most classic ciphers do arithmetic on letters. We number the alphabet from zero and wrap around at 26:
"mod 26" means "keep the remainder after dividing by 26", so 25 + 3 = 28 wraps to 2, and Z shifted by 3 becomes C.
A detail most code gets wrong: in JavaScript, Java and C, -3 % 26 gives −3, not 23. Our tools use ((x % 26) + 26) % 26, so decoding never produces a negative position.
Formulas we use
P is the plain letter, C the coded letter and k the key, all as numbers from 0 to 25.
| Cipher | Encode | Decode | Keys |
|---|---|---|---|
| Caesar cipher | C = (P + k) mod 26 | P = (C − k) mod 26 | 25 shifts (k = 1 to 25) |
| ROT13 | C = (P + 13) mod 26 | Same as encoding | Fixed key |
| Atbash | C = 25 − P | Same as encoding | No key |
| Affine | C = (a·P + b) mod 26 | P = a⁻¹·(C − b) mod 26 | 12 values of a × 26 values of b = 312 |
| Vigenère | Cᵢ = (Pᵢ + Kᵢ) mod 26 | Pᵢ = (Cᵢ − Kᵢ) mod 26 | Any keyword (26ⁿ for length n) |
| Playfair | Pairs on a 5 × 5 square | Reverse the three pair rules | Any keyword |
| Polybius square | Letter → row digit + column digit | Digit pair → letter | Plain or keyword square |
| Rail fence | Zigzag over r rails, read rail by rail | Rebuild rail lengths, then read the zigzag | 2 to 10 rails |
| Bacon | Letter index → 5-digit A/B binary | Each group of 5 → letter | No key |
| Pigpen | Letter → grid symbol | Symbol → letter | No key |
How the shift finder ranks answers
When you don't know the Caesar shift, the decoder tries all 26 keys and scores each result for how much it looks like English.
- Decode with every key. Shifts 0 to 25 each produce a candidate text.
- Score the letters. For each letter, add the log of how often it appears in English (the table below). Common letters like E and T raise the score, rare ones like Q and Z lower it.
- Reward real words. Each candidate gets a bonus of 2.2 points per letter that sits inside a common English word, such as THE, AND or ATTACK, from a list of about 140 words. This rescues short messages where letter counts alone mislead.
- Turn scores into confidence. A softmax turns the 26 scores into percentages that add up to 100. The top key shows first, with every other key ranked below it.
- Break ties. Equal scores fall back to the lower chi-squared distance from English letter counts, then to the smaller shift.
English letter frequency (%)
Values from Robert Lewand, Cryptological Mathematics (Mathematical Association of America, 2000), the table most cryptography courses use.
Short text, names, lists and other languages can fool any statistical method. That's why the full ranked list always stays visible.
How we treat your text
- Case: capital letters stay capital and small letters stay small. The Caesar decoder can force all upper or all lower case.
- Spaces, digits and symbols: kept as they are. The Caesar decoder can keep them, keep only spaces, or remove them.
- Accented letters such as É or Ü: left unchanged, and the tool shows a note.
- Digits: changed only where the cipher covers them: the Caesar A–Z + 0–9 alphabet (36 characters), ROT5, ROT18 and ROT47.
- Custom alphabets (Caesar decoder): spaces and repeated characters are removed, and the shift wraps at the alphabet's own length.
- Vigenère keys: only letters count. The key moves forward on letters and skips spaces and symbols.
Cipher conventions
Some ciphers have more than one version in books and puzzles. These are the versions our tools use.
Playfair
I and J share one cell. Doubled letters in a pair get an X between them (Q if the letter is X), and an odd final letter gets the same filler. You can switch the filler to Q or Z.
Polybius square
A 5 × 5 grid with I and J in one cell. Each letter becomes row then column, so H is 23. A keyword square puts the keyword letters first.
Bacon
Two alphabets. The 24-letter one is Bacon's original, where I = J and U = V. The 26-letter one gives every letter its own code.
Affine
Key a must share no factor with 26, so only 1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23 and 25 work. Other values send two letters to the same place.
Rail fence
2 to 10 rails. The zigzag repeats every 2 × (rails − 1) characters. Spaces can stay in the fence or be removed first.
ROT47
Rotates the 94 printable ASCII characters from ! (33) to ~ (126) by 47, so it changes letters, digits and symbols.
Input checks
Each tool checks your input as you type and explains a problem in plain words instead of showing a wrong answer:
- Number fields reject empty, negative or out-of-range values and snap back to the nearest valid number.
- The affine tool blocks values of a that can't be decoded and says why.
- Polybius, Bacon and Pigpen point out characters their alphabet can't hold.
- Playfair warns when a coded pair repeats a letter, which a real Playfair message never does.
- File uploads accept plain text only and reject empty or binary files.
How we verify results
- Round trip. Every tool encodes test messages and decodes them back. The result must match the original exactly.
- Known answers. We check outputs against published examples, such as the classic Playfair and Vigenère textbook messages.
- Edge cases. Empty input, digits, symbols, accented letters and 20,000-character text all run through every tool.
Read our editorial standards for how we write and review guides.
Found a wrong result?
Email contact@caesarcipherdecoder.com with the page, the text you entered, the key or setting, and the result you expected. We fix confirmed errors within 48 hours and update the date at the top of this page.