🔐 Caesar Cipher
Encode and decode Caesar cipher and ROT13 online. Choose any shift from 1 to 25, or crack unknown text: all 25 shifts ranked by English letter frequency.
What Caesar Cipher Does
This Caesar cipher tool encodes and decodes text with any shift from 1 to 25, including ROT13, and shows the alphabet mapping as you move the slider — useful for learning how the cipher works or checking a puzzle by hand. Capital letters, lowercase letters, spaces and punctuation are preserved, and there is an option to rotate digits as well.
If you have a message but not the key, choose Decode: all 25 possible shifts are listed and ranked by how closely each result matches the letter frequencies of normal English. For anything a sentence or longer, the correct message is almost always at the top; click it to adopt that shift.
How to Use Caesar Cipher
- Choose Encode or Decode, or press ROT13
- Type or paste your text
- Set the shift with the slider and check the alphabet mapping
- Copy the result
- To crack unknown text, use Decode and pick the top-ranked shift
Formula Used by Caesar Cipher
Encoding and decoding
Encode: C = (P + k) mod 26 · Decode: P = (C − k) mod 26
- P, C
- Plain and cipher letters as numbers, A = 0 … Z = 25
- k
- The shift (key)
Worked example
“HELLO” with a shift of 3.
- H (7) → 10 = K
- E (4) → 7 = H
- L (11) → 14 = O
- O (14) → 17 = R
Result: “KHOOR”.
Ranking the 25 candidates
χ² = Σ (observed − expected)² ÷ expected, over the 26 letters
Worked example
A candidate decryption with 100 letters.
- Expected E count = 12.7, T = 9.1, A = 8.2 …
- Compare with the letters actually present
Result: The lowest χ² is the most English-like — usually the real message.
Letter Frequencies in English
| Letter | Frequency | Letter | Frequency |
|---|---|---|---|
| E | 12.7% | N | 6.7% |
| T | 9.1% | S | 6.3% |
| A | 8.2% | H | 6.1% |
| O | 7.5% | R | 6.0% |
| I | 7.0% | D | 4.3% |
How to Read Your Result
A classroom favorite
The Caesar cipher is a gentle introduction to cryptography: it shows what a key is, why a small key space is weak, and how frequency analysis — first described by the Arab scholar al-Kindi in the 9th century — breaks substitution ciphers. It also turns up in escape rooms, geocaching puzzles and scavenger hunts.
Stronger relatives
The Vigenère cipher uses a different Caesar shift for each letter, following a keyword, which defeats simple frequency analysis. Modern encryption such as AES is in a different league entirely and should be used for anything that must stay secret.
Limitations & Accuracy Notes
- Only the 26 letters of the basic Latin alphabet are shifted; accented letters are left unchanged.
- Frequency ranking needs enough text; with a few words, check the top several candidates.
- Not secure encryption.