Caesar Cipher and ROT13: Encode and Decode Messages
Type a message, slide the shift and watch every letter move along the alphabet. Decode with the same number, press ROT13, or list all 25 shifts to crack a puzzle.
A Caesar cipher is a puzzle, not protection. Anyone can undo it in seconds, so never use it for passwords or private information.
This tool runs in your browser. Nothing you type is uploaded or saved, and there is nothing to install or sign up for.
A secret code you can explain in one sentence
The Caesar cipher replaces every letter of a message with the letter a fixed number of places further along the alphabet. With a shift of 3, A turns into D, B into E and C into F, and when you run out of alphabet you start again at A. That is the whole method, which makes it the first cipher most people learn and a favorite for classroom puzzles, scavenger hunts and escape-room clues.
This tool does the letter counting for you. It encodes, decodes, has a one-press ROT13 button and can print all 25 possible shifts at once for a message whose key you do not know.
Encoding and decoding step by step
- Type or paste into Your message.
- Leave the switch on Encode to hide a message, or choose Decode to read one.
- Drag the Shift slider to a number from 1 to 25. The yellow strip shows the plain alphabet with the cipher alphabet lined up beneath it.
- Read the result and press Copy result. To decode, the reader needs the same shift number you used.
- ROT13 jumps straight to shift 13. Show all 25 shifts opens the code-breaking table, and Reset restores the opening example.
Capital letters stay capital and small letters stay small. Spaces, digits, punctuation and accented letters pass through untouched.
Worked example with shift 3
The tool starts with the message Meet me at the library and a shift of 3. Take the first word letter by letter: M moves three places to P, each e moves to h, and t moves to w, so Meet becomes Phhw. The full result is Phhw ph dw wkh oleudub. Notice the y at the end of library: three places past y runs off the end of the alphabet, so it wraps around to b.
To check the work, paste Phhw ph dw wkh oleudub back in, choose Decode and keep the shift at 3. The original sentence returns.
Two shorter cases to try by hand: HELLO with shift 3 is KHOOR, and Zebra with shift 5 is Ejgwf.
The arithmetic behind the shift
Number the letters from A = 0 to Z = 25. Encoding adds the shift and keeps only the remainder after dividing by 26:
cipher = (plain + shift) mod 26
Decoding subtracts instead: plain = (cipher - shift) mod 26. For the letter y, which is number 24, a shift of 3 gives 27, and 27 mod 26 is 1, the letter b. This wrap-around is a neat first meeting with clock arithmetic, and the modulo calculator lets students test remainders like this one.
Because the alphabet is a loop of 26, decoding with shift 3 is the same as encoding with shift 23. A shift of 26 would bring every letter back to itself, which is why the slider stops at 25.
Why ROT13 is special
ROT13 is simply the Caesar cipher with a shift of 13. Thirteen is half of 26, so applying it twice moves each letter all the way round to where it began. One button therefore both hides and reveals: Hello, World! becomes Uryyb, Jbeyq!, and running ROT13 on that gives the greeting back. It is often used to blur a puzzle answer or a story spoiler so nobody reads it by accident.
Breaking a message without the key
There are only 25 useful shifts, so the quickest attack is to try them all. Paste a mystery message, press Show all 25 shifts and scan the table for the one row that reads as English. For Wkh txlc lv rq Iulgdb, row 3 says The quiz is on Friday.
A second approach is letter counting. In ordinary English writing, E tends to be the most frequent letter. If the most common letter in a long coded message is H, the shift is probably 3, since H is three places after E. This works poorly on short messages, where the table is faster.
| Shift | A becomes | HELLO becomes |
|---|---|---|
| 1 | B | IFMMP |
| 3 | D | KHOOR |
| 13 (ROT13) | N | URYYB |
| 25 | Z | GDKKN |
Where the name comes from
The cipher is named after Julius Caesar. The Roman biographer Suetonius, in his life of Caesar, wrote that Caesar put confidential passages of his letters into cipher and that a reader had to substitute the fourth letter of the alphabet, D, for A, and so on with the others (Suetonius, The Deified Julius, chapter 56, Loeb translation, read December 2026). That is a shift of three, the default on this page.
It makes a good history lesson because students can do exactly what a Roman reader did. Ask why such a simple trick might have been enough at the time, and what changed once people learned to try every shift.
Classroom puzzle ideas
- Daily starter. Write an encoded fact on the board and reveal only the shift. The first table to decode it explains how they did it.
- Vocabulary review. Encode ten spelling or science words. Decoding forces students to look closely at every letter.
- Code-breaking race. Hand out a message with no key and let teams discover the try-every-shift method on their own.
- Treasure hunt. Each clue is encoded with a different shift, and the shift for the next clue is hidden in the current answer.
- Math link. Have students encode by hand using the formula, then use the tool to mark their own work.
What this cipher cannot do
The Caesar cipher gives no real security. With 25 keys, a person can break it in a minute and a computer instantly. Never use it to protect passwords, personal details or anything that matters.
It also changes letters A to Z only. Numbers, symbols, emoji and letters with accents are copied across as they are, so a date or a phone number in your message stays readable. And the shape of the message survives: word lengths, capital letters and punctuation all give hints to a solver, which is part of what makes it a fair puzzle.
More code and word puzzles
For another classic code, the Morse code translator turns letters into dots and dashes. The word scrambler makes anagram puzzles from a word list, and the reverse text generator writes a message backward for a quick mirror-writing challenge.
All of these are in the text tools section, and the full tool index has timers, pickers and calculators for the rest of the lesson.
Frequently asked questions
How do I decode a Caesar cipher?
Paste the message, choose Decode and set the shift that was used to encode it. If you do not know the shift, press Show all 25 shifts and pick the row that reads as normal English.
What is the Caesar cipher with a shift of 3?
Each letter moves three places forward, so A becomes D, B becomes E and X, Y, Z wrap around to A, B, C. HELLO becomes KHOOR.
What is ROT13?
ROT13 is a Caesar cipher with a shift of 13. Because 13 is half of the 26-letter alphabet, applying it a second time gives back the original text. Hello becomes Uryyb.
Is the Caesar cipher secure?
No. There are only 25 possible shifts, so anyone can try them all in moments. It is a puzzle and teaching cipher and should never protect real secrets.
What happens to numbers and punctuation?
They are left unchanged. Only the 26 letters A to Z are shifted, and capital and small letters keep their case.
Why is it called the Caesar cipher?
It is named after Julius Caesar. The Roman writer Suetonius recorded that Caesar wrote confidential parts of his letters by replacing A with D and shifting the other letters the same way.
