What is the Caesar cipher?
The Caesar cipher, also called the Caesar shift or Caesar code, replaces each letter with the letter a fixed number of places further along the alphabet. That number is the key, usually called the shift. With a shift of 3, A becomes D, B becomes E, and Z wraps around to C. It is one of the oldest known ciphers and often the first one people meet when they start learning cryptography.
| Text | H | E | L | L | O |
|---|---|---|---|---|---|
| Shift 3 | K | H | O | O | R |
How to use this Caesar cipher translator
- Choose Encrypt to turn text into code, or Decrypt to turn code back into text.
- Type or paste your message into the text box.
- Set the shift with the slider or the plus and minus buttons. You can also drag the alphabet itself.
- Read the result as it updates, then copy it. If your message uses letters outside A to Z, pick a different alphabet first.
How to decode a Caesar cipher
If you know the shift, switch to Decrypt and set the same number. Our Caesar cipher decoder moves every letter back by that many places.
If you don’t know the shift, use the solver. The standard alphabet allows only 25 shifts, so the solver tries them all and ranks the results by how closely they resemble the language you select. To learn how this works, read our guides to cracking the cipher without the key and brute force attacks.
The Caesar cipher formula
Number the letters from A = 0 to Z = 25. To encrypt a letter x with a shift n, add the shift and wrap around with modulo 26. To decrypt, subtract the shift.
E(x) = (x + n) mod 26
D(x) = (x − n) mod 26 Take the letter X, which is 23, with a shift of 3. 23 + 3 = 26, and 26 mod 26 = 0, so X becomes A.
Want to write it yourself? Follow our tutorials in Python, JavaScript, Java, C and PHP, or start with the beginner’s guide.
Alphabets, diacritics and special characters
The alphabet you pick decides which characters get shifted. Everything outside it, such as spaces, digits and punctuation, stays as it is.
| Alphabet | What gets shifted |
|---|---|
| Basic (A-Z) | The 26 letters from A to Z. Accented letters such as é, ü or ñ stay unchanged. |
| Polish | A to Z plus Ą, Ć, Ę, Ł, Ń, Ó, Ś, Ź and Ż, 35 letters in total. |
| German | A to Z plus Ä, Ö, Ü and ß, 30 letters in total. |
| Spanish | A to Z plus Ñ, 27 letters in total. |
| French | A to Z. Accented letters are first converted to their base letter, so é is treated as e. |
| Custom | Only the characters you type into the custom alphabet field. |
Examples with a shift of 1
| Text | Alphabet | Result |
|---|---|---|
| café | Basic (A-Z) | dbgé |
| café | French | dbgf |
| żółw | Basic (A-Z) | żółx |
| żółw | Polish | apmx |
Where the name comes from
The cipher is named after Julius Caesar. The Roman historian Suetonius wrote that Caesar used a shift of 3 in his private letters, and that Augustus later used a shift of 1. For the full story, read the history of the Caesar cipher.
Is the Caesar cipher secure?
No. With only 25 possible shifts, anyone can try them all in seconds. The cipher also keeps letter patterns intact, so the most common letter in the code usually stands for a common letter such as E. You can see this for yourself with our frequency analysis tool. Use the Caesar cipher for learning, puzzles and games, and never to protect passwords or private data.
ROT13: the Caesar cipher with a shift of 13
ROT13 is a Caesar cipher with a fixed shift of 13. Because 13 is half of 26, applying it twice gives you back the original text, so the same step both encodes and decodes. People often use it to hide spoilers and puzzle answers. Set the slider above to 13 or open our ROT13 tool.
Frequently asked questions
Is the Caesar cipher always a shift of 3?
No. A shift of 3 is the classic example because Caesar is said to have used it, but any shift from 1 to 25 works with the standard alphabet.
How do you write “I love you” in Caesar cipher?
With a shift of 3, I LOVE YOU becomes L ORYH BRX. A different shift gives a different result.
Is the Caesar cipher the same as ROT13?
ROT13 is one specific Caesar cipher, the one with a shift of 13. The Caesar cipher covers every possible shift.
Is my text sent to your server?
No. The encoder, decoder and solver on this page run in your browser, so your text is not sent to our server.
Why does my decoded text still look wrong?
Check that the mode is set to Decrypt, and that the shift and alphabet match the ones used to encrypt. If you do not know the shift, the Solver mode tries them all.