Caesar cipher encoder, decoder and solver
This Caesar cipher tool shifts every letter of your text a fixed number of places along the alphabet. You can encode with any shift, decode when you know the shift, or break an unknown message by trying all 25 possibilities at once. The brute-force mode ranks every candidate against English letter frequencies and common words and marks the most likely answer.
What is the Caesar cipher?
The Caesar cipher is one of the oldest known substitution ciphers. According to the Roman historian Suetonius, Julius Caesar used a shift of three for private letters, so A became D, B became E and so on, wrapping around so that X, Y and Z became A, B and C. The same idea with a shift of 13 is known as ROT13.
Mathematically, each letter is converted to a number from 0 to 25, the shift is added modulo 26, and the result is converted back to a letter. Decoding subtracts the shift instead.
Example
Encoding the sample sentence with the default shift of 3:
Meet me at the old bridge at midnight.
→ Phhw ph dw wkh rog eulgjh dw plgqljkw.
Now suppose you only have the ciphertext. Brute force (all 25) prints every decoding, one per line, and stars the best one:
1 Oggv og cv vjg qnf dtkfig cv okfpkijv.
2 Nffu nf bu uif pme csjehf bu njeojhiu.
3 ★ Meet me at the old bridge at midnight.
4 Ldds ld zs sgd nkc aqhcfd zs lhcmhfgs.
5 Kccr kc yr rfc mjb zpgbec yr kgblgefr.
…
25 Qiix qi ex xli sph fvmhki ex qmhrmklx.
The status bar confirms "Most likely shift: 3". Each line number is the shift that was undone to produce that line.
How the automatic detection works
For every candidate, the solver calculates how typical its letters are for English. Letters like E, T, A and O are common, while J, Q, X and Z are rare, so a line full of common letters scores better. It then adds a bonus for recognizable English words such as "the", "and", "at" or "meet". The line with the best combined score gets the star.
This works well for sentences of a few words or more. Very short inputs, lists of names, or text in another language can fool it, so glance at the other lines if the starred one does not look right.
Options and behavior
- Shift accepts -25 to 25. A negative shift moves letters backward, so encoding with -3 is the same as decoding with 3. Shifts are reduced modulo 26, and the status bar shows the effective value.
- Case is preserved: uppercase stays uppercase and lowercase stays lowercase.
- Non-letters are untouched: spaces, digits, punctuation and accented characters pass through unchanged, which keeps word boundaries visible.
Is the Caesar cipher secure?
No. There are only 25 useful keys, so anyone can try them all in a fraction of a second, exactly as this tool does. Even without a computer, letter frequency analysis breaks it by hand. Treat it as a puzzle, teaching aid or light obfuscation, never as protection for passwords or private data.
If you want something harder to crack by hand, the Vigenère cipher uses a keyword so each letter can shift by a different amount. It is still a classical cipher, though, and falls to well-known statistical attacks.
Where you will see Caesar shifts
- Escape rooms, geocaching puzzles and scavenger hunts.
- Introductory cryptography and programming classes, where writing a shift function is a classic exercise.
- Capture-the-flag challenges, often combined with other encodings such as Morse code.
Privacy
All shifting and scoring runs locally in your browser. The text you enter is never uploaded.