Caesar Cipher Encoder / Decoder
Encode or decode text with a classic Caesar shift cipher.
Encode or decode text with a classic Caesar shift cipher.
The Caesar Cipher Encoder / Decoder shifts each letter in your text forward or backward through the alphabet by a chosen number of positions. It is one of the oldest known ciphers and is useful for puzzles, learning about cryptography basics or simple text obfuscation.
The Caesar cipher, one of the oldest known encryption techniques, shifts each letter of the alphabet by a fixed number of positions, and while it's now purely educational rather than secure, it remains a popular first introduction to the basic concepts behind more modern cryptography.
For related tasks, try Base64 Encoder / Decoder, URL Encoder / Decoder or Text to ASCII Converter.
Each letter is moved a fixed number of positions through the alphabet, wrapping from Z back to A, while case is preserved and non-letter characters are left unchanged.
With a shift of 3, “HELLO” encodes to “KHOOR”. Decoding “KHOOR” with the same shift of 3 returns “HELLO”.
With a shift of 3, the classic Caesar cipher setting, the word ATTACK encodes to DWWDFN, since each letter moves forward three positions in the alphabet, wrapping back to the start of the alphabet if it passes Z.
Because a Caesar cipher only has 25 possible shift values, it can be broken almost instantly by simply trying every possible shift or through basic frequency analysis of letter patterns, so it should never be used to protect genuinely sensitive information.
The Caesar cipher replaces each letter with the letter a fixed number of places further along the alphabet. With a shift of 3, HELLO becomes KHOOR, and letters at the end wrap around, so X becomes A. Decoding shifts back by the same amount. Julius Caesar is reported to have used a shift of 3 for military messages. Digits, spaces and punctuation are normally left unchanged.
A shift of 13 is called ROT13. Because the alphabet has 26 letters, applying ROT13 twice returns the original text, so the same operation encodes and decodes. It is used online to hide spoilers and puzzle answers, not to protect secrets. Any shift from 1 to 25 gives a different message, and a shift of 26 returns the original. Choose a shift and share it with the person who will decode the message.
There are only 25 possible shifts, so a person can try all of them in seconds. Letter frequency analysis breaks it as well: in English the letter E is the most common, so the most common letter in the coded text probably stands for E, which reveals the shift. Modern encryption uses far larger key spaces and mathematically tested algorithms. Never use a Caesar cipher to protect real information.
The cipher is a good first step into cryptography. Teachers use it to explain keys, encoding and decoding, and puzzle writers use it for treasure hunts and escape rooms. Try breaking a message by testing each shift, and then look at how a Vigenere cipher improves things by using a keyword to change the shift for each letter. Understanding why simple methods fail helps explain why modern systems are built the way they are.
If you receive a message that you suspect is a Caesar cipher, try each shift. The text KHOOR ZRUOG, shifted back by 3, becomes HELLO WORLD. Look for a result that forms real words. You can also use letter frequency: in English the letter E is the most common, so find the most common letter in the coded text and assume it stands for E, which gives you the shift. A short message may need several attempts, since few letters make the statistics unreliable.
To encode MEET AT DAWN with a shift of 5, move each letter five places forward in the alphabet: M becomes R, E becomes J, E becomes J and T becomes Y, so the first word is RJJY. In the same way, AT becomes FY and DAWN becomes IFBS, since W wraps around past Z to B. The message reads RJJY FY IFBS. To decode, shift each letter back by five. Spaces and punctuation stay unchanged, which gives away the length of the words and makes the cipher easier to break.
Suppose you receive WKLV LV D WHVW and suspect a shift. Try shifts until the text makes sense. A shift of 3 backwards turns W into T, K into H, L into I and V into S, giving THIS IS A TEST. For longer texts, count the letters. In English the most frequent letter is usually E, so if the most common letter in the ciphertext is H, a shift of 3 is likely. With only 25 possible shifts, a person can try them all in a minute, and a computer does it instantly. This is why the cipher is a toy and not a security tool.
Julius Caesar reportedly used a shift of three for private letters, as described by the Roman historian Suetonius. Later ciphers improved on the idea. The Vigenere cipher, developed in the sixteenth century, uses a keyword to change the shift for each letter, which hides letter frequencies better. Mechanical machines such as Enigma in the twentieth century used many rotating wheels. Modern systems like AES use complex mathematics and keys long enough that trying every possibility is impossible. Studying the Caesar cipher shows the basic ideas of a key, an algorithm and an attack.
Teachers use the Caesar cipher to introduce cryptography, modular arithmetic and programming. A cipher wheel with two rings makes the shift visible. In code, the shift for an uppercase letter is calculated as the letter's position, plus the key, modulo 26. Students can write a program to encode, decode and break messages, and then discuss why the method fails. ROT13 is still used in online forums to hide spoilers. When you use the tool, try a message of your own, share it with a friend and see how quickly they can decode it.
Plaintext is the original message and ciphertext is the encoded one. A key is the secret information that controls the encoding, which in this cipher is the shift. Encryption turns plaintext into ciphertext and decryption reverses it. A substitution cipher replaces each letter with another. Frequency analysis uses letter counts to find a key. A brute-force attack tries every possible key. ROT13 is the shift of thirteen, and Vigenere is a cipher that uses a keyword.
A shift of n moves each letter n places, wrapping around after Z, and a shift of 26 returns the original. To decode, shift by 26 minus n. There are only 25 useful keys. In English text, the most common letter is E, followed by T and A. If a decoded text is nonsense, try the next shift. For any real secret use modern encryption instead, since this cipher offers no real protection.
No. It is easily broken and intended for education and simple puzzles rather than real security.
They are left unchanged; only letters are shifted.
Yes, any whole number works since the shift wraps around the 26-letter alphabet.
No, it's easily broken through simple brute-force testing of all 25 possible shifts or basic letter-frequency analysis; it should be treated as an educational or puzzle tool only, never for actual security.
Historical accounts suggest Caesar used a shift of 3, which is why that particular shift value is often used as the default example when demonstrating this cipher.