T

Text Machine

Powerful text tools, in your browser

Caesar Cipher

Encode, decode, and crack the classic Caesar shift cipher. Choose any shift from 1 to 25, jump to ROT13, ROT5, or ROT47, or let Crack mode try all 25 shifts and auto-detect the most likely one. Everything runs in your browser.

Shift

3
Plain text
Ciphertext

Enter text above to see the result here.

Alphabet mapping

Plain

A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z

Cipher

D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
A
B
C

How to use Caesar Cipher

  1. 1

    Choose encode, decode, or crack

    Encrypt plain text into ciphertext, decrypt ciphertext back into plain text, or switch to Crack to break a message when you do not know the shift.

  2. 2

    Pick a shift or a preset

    Set any shift from 1 to 25 with the plus and minus buttons, or tap a preset: ROT13 for the classic letter shift of 13, ROT5 for digits, or ROT47 for all printable symbols.

  3. 3

    Enter your text

    Type or paste your message. The cipher runs automatically as you type, shifting each letter along the alphabet by the amount you set while numbers and punctuation pass through.

  4. 4

    Crack a message without the key

    In Crack mode, paste the ciphertext and the tool decodes it with all 25 shifts, then uses letter-frequency analysis to highlight the most likely plain text for you.

  5. 5

    Copy, download, or share

    Copy the result to your clipboard, download it as a text file, or share a link that reopens the tool with your exact text and settings ready to go.

Understanding the Caesar Cipher

What is the Caesar cipher?

The Caesar cipher is a substitution cipher that encrypts a message by shifting every letter a fixed number of places along the alphabet. It is named after the Roman general Julius Caesar, who reportedly used a shift of three to protect his private and military correspondence. Because each letter is always replaced by the same substitute, the Caesar cipher is the simplest and most widely taught example of classical cryptography, and it remains a perfect starting point for learning how encryption works.

Today the Caesar cipher turns up in puzzles, escape rooms, capture-the-flag challenges, and beginner programming exercises. Its most famous variant, ROT13, is still used across the web to hide spoilers, punchlines, and answers in plain sight.

How Caesar cipher encryption works

To encrypt, you pick a shift value, called the key, between 1 and 25. Each letter of your message then moves forward through the alphabet by that many positions, wrapping around from Z back to A when it runs off the end. Decryption reverses the process, shifting each letter backward by the same amount. Spaces, digits, and punctuation are normally left untouched, which is why the shape and length of the original message stay visible in the ciphertext.

For example, with a shift of three the letter A becomes D, B becomes E, and the word HELLO turns into KHOOR. To read the message, the recipient only needs to know the single shift value and move every letter three places back.

Worked example: a shift of three

Take the classic phrase ATTACK AT DAWN and apply Caesar's own shift of three. A maps to D, T maps to W, C maps to F, K maps to N, and so on, producing the ciphertext DWWDFN DW GDZQ. Notice that the spaces stay in place and repeated letters always encrypt to the same character, so the double T in ATTACK becomes a double W. Reversing the shift turns DWWDFN DW GDZQ straight back into ATTACK AT DAWN.

The Caesar cipher formula

Mathematically, each letter is treated as a number from 0 to 25, where A is 0 and Z is 25. Encryption is written as E(x) = (x + n) mod 26 and decryption as D(x) = (x - n) mod 26, where x is the letter's position and n is the shift. The mod 26 operation is what makes the alphabet wrap around, so shifting Y by three lands on B instead of running past the end of the alphabet.

ROT13, ROT5, and ROT47 explained

ROT13 is a Caesar cipher locked to a shift of thirteen. Because thirteen is exactly half of twenty-six, applying ROT13 twice returns the original text, so a single operation both encodes and decodes. ROT5 applies the same idea to the ten digits 0 through 9, which makes it handy for masking numbers, while ROT47 rotates all 94 printable ASCII characters together, scrambling letters, digits, and punctuation at once. Each of these is self-inverse, which is exactly what makes them so convenient for quickly hiding and revealing short pieces of text.

How to break a Caesar cipher

The Caesar cipher has only 25 possible keys, which makes it trivially easy to break. The most direct method is a brute-force attack: decode the message with every shift from 1 to 25 and read whichever result makes sense. A smarter approach is frequency analysis, which compares the letter distribution of each candidate against the typical frequencies of English, where E, T, and A are the most common letters, and picks the closest match automatically. The Crack mode in this tool does both for you, listing all 25 decodings and highlighting the most likely answer using a chi-squared score.

A short history of the Caesar cipher

The cipher takes its name from Julius Caesar, who according to the historian Suetonius shifted each letter three places to keep his messages private around 50 BC. His successor Augustus is said to have used a similar scheme with a shift of one. For centuries a simple letter shift was secure enough, mostly because so few people could read, let alone analyse a coded message. Its weakness was understood by the ninth century, when the Arab mathematician Al-Kindi described frequency analysis, the very technique that breaks the cipher in seconds today.

Is the Caesar cipher secure?

No. With only 25 keys, a Caesar cipher can be broken by hand in a couple of minutes and by a computer instantly, so it offers no protection for anything that genuinely needs to stay secret. Its value today is educational and recreational: it is an ideal way to learn the vocabulary of cryptography, such as plaintext, ciphertext, key, encryption, and cryptanalysis, and a fun building block for puzzles, games, and coding projects. For real security, modern algorithms such as AES are used instead.

Caesar cipher chart: all 25 shifts

This reference chart lists the ciphertext alphabet for every Caesar shift from 1 to 25. Find your shift in the left column, then read across: the row shows what the plain letters A through Z turn into. The highlighted row is ROT13, the shift of 13 that both encodes and decodes.

ShiftCipher alphabet (A to Z)
1BCDEFGHIJKLMNOPQRSTUVWXYZA
2CDEFGHIJKLMNOPQRSTUVWXYZAB
3DEFGHIJKLMNOPQRSTUVWXYZABC
4EFGHIJKLMNOPQRSTUVWXYZABCD
5FGHIJKLMNOPQRSTUVWXYZABCDE
6GHIJKLMNOPQRSTUVWXYZABCDEF
7HIJKLMNOPQRSTUVWXYZABCDEFG
8IJKLMNOPQRSTUVWXYZABCDEFGH
9JKLMNOPQRSTUVWXYZABCDEFGHI
10KLMNOPQRSTUVWXYZABCDEFGHIJ
11LMNOPQRSTUVWXYZABCDEFGHIJK
12MNOPQRSTUVWXYZABCDEFGHIJKL
13 · ROT13NOPQRSTUVWXYZABCDEFGHIJKLM
14OPQRSTUVWXYZABCDEFGHIJKLMN
15PQRSTUVWXYZABCDEFGHIJKLMNO
16QRSTUVWXYZABCDEFGHIJKLMNOP
17RSTUVWXYZABCDEFGHIJKLMNOPQ
18STUVWXYZABCDEFGHIJKLMNOPQR
19TUVWXYZABCDEFGHIJKLMNOPQRS
20UVWXYZABCDEFGHIJKLMNOPQRST
21VWXYZABCDEFGHIJKLMNOPQRSTU
22WXYZABCDEFGHIJKLMNOPQRSTUV
23XYZABCDEFGHIJKLMNOPQRSTUVW
24YZABCDEFGHIJKLMNOPQRSTUVWX
25ZABCDEFGHIJKLMNOPQRSTUVWXY

Frequently asked questions

What is the Caesar cipher?
The Caesar cipher is one of the oldest known encryption methods, named after Julius Caesar, who used it to protect military messages. It replaces each letter with another a fixed number of positions further along the alphabet. A shift of 3, for example, turns A into D and B into E, wrapping around from Z back to A.
What is ROT13?
ROT13 is a Caesar cipher with a shift of 13. Because the alphabet has 26 letters, shifting by 13 twice returns the original text, so the same operation both encodes and decodes. It is commonly used online to hide spoilers, punchlines, and puzzle answers rather than for real security.
What are ROT5 and ROT47?
ROT5 rotates the digits 0 to 9 by five places and leaves letters alone, so it is handy for masking numbers. ROT47 rotates all 94 printable ASCII characters, including letters, digits, and punctuation, by 47 positions. Both are self-inverse, meaning the same action encodes and decodes, just like ROT13.
How do I decode a message without knowing the shift?
Switch to Crack mode and paste the ciphertext. The tool decodes it with every shift from 1 to 25 and ranks the results, using letter-frequency analysis to highlight the most likely plain text. Because there are only 25 possible shifts, the Caesar cipher is quick and easy to break this way.
How does the automatic solver work?
For each of the 25 possible shifts, the solver decodes the text and measures how closely its letter distribution matches ordinary English using a chi-squared score. The shift whose decoding looks most like English is shown as the best guess. The more text you provide, the more reliable the detection becomes.
Does it change numbers, spaces, or punctuation?
In the standard Caesar and ROT13 modes only the letters A to Z are shifted, and each keeps its uppercase or lowercase form, while digits, spaces, and punctuation pass through unchanged. ROT5 shifts only digits, and ROT47 deliberately shifts letters, digits, and symbols together.
What is the Caesar cipher formula?
Encryption is E(x) = (x + n) mod 26 and decryption is D(x) = (x - n) mod 26, where x is the position of a letter from 0 to 25 and n is the shift. The mod 26 keeps the result inside the alphabet, which is what makes the letters wrap from Z back to A.
How many shifts are possible, and is it secure?
There are only 25 useful shifts, since a shift of 0 or 26 leaves the text unchanged. That tiny key space means anyone can try them all in seconds, so the Caesar cipher offers no real security today and is best treated as a fun, educational, or puzzle tool.
Why did Julius Caesar use a shift of three?
According to the Roman historian Suetonius, Caesar shifted each letter three places to conceal his correspondence. A fixed shift of 3 was enough in an era when most enemies could not read at all, let alone perform cryptanalysis, which is why this simple scheme still carries his name two thousand years later.
Is my text uploaded to a server?
No. All encoding, decoding, and cracking happens entirely in your browser, so your text is never uploaded, logged, or stored. Even a share link keeps your text in the part of the URL after the hash, which browsers never send to a server, so it stays private until you choose to share it.
How do I know if a message is a Caesar cipher?
A Caesar cipher keeps the word lengths, spacing, and punctuation of the original, so the text looks like real language with the letters swapped. A strong clue is the letter-frequency pattern: because every letter moves by the same amount, the usual English frequency curve simply slides along the alphabet, so one letter ends up dominating the way E normally would. If switching to Crack mode and trying all 25 shifts produces readable text at exactly one shift, it was almost certainly a Caesar cipher. If no single shift works, the message may use a different method such as the Vigenère cipher or a mixed substitution cipher.
What is the difference between the Caesar cipher and ROT13?
ROT13 is simply a Caesar cipher with the shift fixed at 13. The general Caesar cipher lets you choose any shift from 1 to 25, while ROT13 always uses 13. Because 13 is exactly half of 26, ROT13 is its own inverse: running text through it twice returns the original, so one action both encodes and decodes. A Caesar cipher with any other shift needs the opposite shift to decode.
What is the difference between the Caesar cipher and the Vigenère cipher?
The Caesar cipher uses one fixed shift for the whole message, so it has only 25 possible keys and is easy to break. The Vigenère cipher uses a keyword to apply a different shift to each letter in turn, which hides the letter-frequency pattern and makes it far harder to crack. In effect, Vigenère is a series of Caesar ciphers cycling through the letters of the key, which is why it was long known as le chiffre indéchiffrable, the indecipherable cipher.
Can you show some Caesar cipher examples with answers?
With a shift of 3, HELLO becomes KHOOR and the message ATTACK AT DAWN becomes DWWDFN DW GDZQ. Caesar's motto VENI VIDI VICI encrypts to YHQL YLGL YLFL, and the phrase ET TU BRUTE becomes HW WX EUXWH. To decode any of these, apply the opposite shift of 3 in Decode mode, or paste the ciphertext into Crack mode and let the solver find the shift for you.
What other names does the Caesar cipher have?
The Caesar cipher is also known as the shift cipher, the Caesar shift, Caesar's code, or simply the Caesar code, because each letter is shifted by a fixed amount. Specific shifts have their own names: a shift of 13 is ROT13, a shift of 1 is sometimes called the August cipher after Caesar's successor Augustus, and the wider family of fixed-rotation ciphers is written as ROT-N. They all work the same way and are decoded with this tool.
How do I write a Caesar cipher in code?
The algorithm is short in any language. Loop over each character and check whether it is a letter; if it is, subtract the code of A to get a number from 0 to 25, add the shift, take the remainder after dividing by 26 so the alphabet wraps around, then add the code of A back and turn the number into a character. Non-letters are copied through unchanged. In Python the ord and chr functions handle the conversions, and in JavaScript charCodeAt and fromCharCode do the same, which is exactly how this in-browser tool works.

Related tools

Keep going with these handy tools

Vigenère Cipher

Atbash Cipher

Rail Fence Cipher

Playfair Cipher

Affine Cipher

Baconian Cipher