Caesar Cipher Encoder & Decoder
Shift letters by any amount — or let frequency analysis find the shift for you.
Every character once, in order. Spaces are ignored; letters given in one case match both cases.
Encrypted text
Type a message above.
Every shift, best fit to English first
Each row decrypts your text with one shift. χ² (chi-squared) measures how far its letter counts are from English: χ² = Σ (observed − expected)² ÷ expected, where expected = letters × English frequency. Lower is closer to English.
| # | Shift | χ² | Action | Decrypted text |
|---|
Letter frequencies of the best guess compared with English
| Letter | Count | This text | English | Comparison | χ² part |
|---|
This text English (Lewand 2000)
Step by step: how this shift works
| Plain |
|---|
| Cipher |
About the Caesar Cipher Encoder & Decoder
A Caesar cipher replaces each letter with the letter a fixed number of places further along the alphabet. With a shift of 3, A becomes D, B becomes E, and X, Y, Z wrap round to A, B, C. According to the Roman historian Suetonius, Julius Caesar used exactly this shift to protect his messages, which is how the cipher got its name.
This tool encrypts and decrypts with any shift — negative shifts and shifts above 25 included — and with your own alphabet, such as A–Z followed by 0–9. Capitals, spaces and punctuation are kept. If you have a message but not the shift, Crack tries every shift and ranks the results by how closely their letter counts match English, using the chi-squared test and Robert Lewand’s English letter frequencies. Step by step works through each letter, so you can follow the maths.
How to use it
- Choose Encrypt, Decrypt or Crack an unknown shift.
- Type or paste your message.
- To encrypt or decrypt, set the shift — 3 is Caesar’s own, 13 is ROT13 — and the alphabet if you need digits or another set of letters.
- To crack, read the best guess and the ranked list of all 25 shifts; press Use on any row to decrypt with that shift instead.
- Copy or download the result, or press Use as input to work on it further. Open Step by step to see each letter being shifted.
Examples
Veni, vidi, vici
Yhql, ylgl, ylfl
V (position 21) + 3 = 24 → Y; i (8) + 3 = 11 → l. Capitals and punctuation stay.
QEB NRFZH YOLTK CLU GRJMP LSBO QEB IXWV ALD
THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG
A shift of −3 is the same as a shift of 23 for the 26 letters.
Phhw ph dw wkh rog oleudub diwhu wkh ohfwxuh. Eulqj wkh pds dqg frph dorqh.
Shift 3: Meet me at the old library after the lecture. Bring the map and come alone.
Shift 3 scores χ² = 19.2; the runner-up, shift 22, scores 125.2. Try an example in Crack mode loads this message.
Common uses
- Solving puzzles, escape-room clues, geocaches and CTF challenges that use a shift cipher.
- Teaching or learning modular arithmetic and the basics of cryptanalysis with a worked, step-by-step example.
- Writing secret notes for games and treasure hunts, with digits included through a custom alphabet.
- Checking homework on encryption, decryption and frequency analysis.
The maths
Number the letters from 0: A = 0, B = 1 … Z = 25. Encrypting with shift k is E(x) = (x + k) mod 26 and decrypting is D(x) = (x − k) mod 26, where “mod 26” wraps a result past Z back to the start: Y (24) + 3 = 27, and 27 mod 26 = 1, which is B.
Shifts repeat every 26, so 29 works like 3 and −3 like 23. With a custom alphabet the same formulas use its length instead of 26: with A–Z followed by 0–9, Z shifted by 1 becomes 0.
How the cracking works
In English, letters appear with typical frequencies: E about 12.7 %, T 9.1 %, A 8.2 %, but Q and Z under 0.1 % (Robert Lewand, Cryptological Mathematics). For each shift the tool decrypts your text, counts each letter (O), works out the count English would lead you to expect (E = number of letters × frequency) and adds up χ² = Σ (O − E)² ÷ E. The right shift produces English-looking counts and the lowest χ²; wrong shifts put common letters in rare places and score far higher.
This is frequency analysis, first described in the 9th century by the Arab scholar al-Kindi in A Manuscript on Deciphering Cryptographic Messages. Open the letter-frequency table under the results to see how the best guess compares with English, letter by letter.
Why a Caesar cipher is not secure
There are only 25 useful shifts, so anyone can try them all in seconds, and frequency analysis points to the right one even faster. Treat it as a puzzle or a teaching tool, never as protection for real secrets. ROT13 is the special case with shift 13, which encrypts and decrypts with the same step.
Limitations
- Ranking compares with English letter frequencies. For other languages the right shift may not come first — read the top few rows.
- With fewer than about 20 letters, frequency analysis is unreliable; the page warns you and lists every shift anyway.
- Only ciphers with one shift for the whole message are solved here. Vigenère and other ciphers that change the shift from letter to letter are not.
- Characters that are not in the chosen alphabet, such as é or ñ in the A–Z alphabet, are copied unchanged.
- In an alphabet that mixes letters with digits (such as A–Z then 0–9), a capital letter that is shifted onto a digit loses its case, because digits have none: it comes back as a small letter when you decrypt.
- Very long texts are ranked on their first 20,000 characters; the chosen shift is then applied to the whole text.
Privacy
Everything happens in your browser. What you enter or open here is not uploaded or stored by MySmartCoPilot.
Frequently asked questions
How do I decode a Caesar cipher without knowing the shift?
Choose Crack an unknown shift and paste the message. Every shift is tried and ranked by how English the result looks; the best guess is shown straight away. With 20 or more letters of English text the right shift is almost always first.
What shift did Julius Caesar use?
A shift of 3, according to Suetonius: A was written as D, B as E, and so on. Press 3 (Caesar) to use it.
Is ROT13 a Caesar cipher?
Yes, ROT13 is a Caesar cipher with a shift of 13. Because 13 is half of 26, the same shift both encrypts and decrypts; the ROT13 tool also has ROT5, ROT18 and ROT47.
How many keys does a Caesar cipher have?
For the 26-letter alphabet there are 25 shifts that change the text (a shift of 0 or 26 leaves it as it is). With a custom alphabet of n characters there are n − 1.
Can I include numbers or use another alphabet?
Yes. Choose A–Z then 0–9 to shift digits along with letters, or Custom alphabet and type any characters in the order you want, such as a Greek or Hindi alphabet. Each character may appear only once.
What does χ² (chi-squared) mean in the results?
It measures how far a text’s letter counts are from what English would give for the same number of letters; zero would be a perfect match. For a few sentences the right shift typically scores in the tens and wrong shifts in the hundreds. The numbers grow with the length of the text, so compare the rows with each other rather than with a fixed limit.