Converters & translators

Caesar Cipher Decoder & Encoder

Encode and decode the Caesar shift cipher with any shift from 1 to 25, or crack a message without the key: every shift is tried and ranked for you.

Updated · Free, no sign-up

Encoded
Khoor Zruog

Share this tool

Know someone who’d love it?

What is the Caesar cipher?

The Caesar cipher (also called the Caesar shift or shift cipher) replaces every letter with the letter a fixed number of places further along the alphabet. With a shift of 3, A becomes D, B becomes E and C becomes F. At the end of the alphabet you wrap around to the start, so X becomes A, Y becomes B and Z becomes C. To read the message again you shift every letter back by the same number. The number of places, from 1 to 25, is the whole key.

It is the simplest substitution cipher there is, which makes it the classic first step into codes: escape rooms, treasure hunts, classroom puzzles and geocaches use it all the time. It is also very easy to break, and this tool shows you how.

How to use the Caesar cipher decoder and encoder

  1. Choose Encode to hide a message or Decode to read one.
  2. Set the shift with the − and + buttons or type a number from 1 to 25. The default, 3, is the shift the cipher is famous for.
  3. Type or paste your text. The result appears as you type; capital and small letters stay as they are, and spaces, digits and punctuation pass through unchanged.
  4. Copy the result, or press Decode this to send it back through the other way and check it.

Below the result are four sections you can open:

  • Crack it: I don’t know the key tries all 25 shifts and ranks them by how much the result looks like English, using letter patterns and our dictionary. The right answer is almost always at the top. Press Use shift to apply it.
  • Step by step draws a cipher wheel turned to your shift, the plain and cipher alphabets lined up, and the arithmetic for the first letters of your text.
  • Letter frequencies counts the letters in your text and puts them next to typical English, the method code breakers use on longer messages.
  • Which cipher is this? guesses what kind of code a message uses, if you are not sure it is a Caesar shift at all.

You can also open the tool already filled in from a link: ?text=Khoor&mode=decode&shift=3 decodes a message straight away, and &open=crack opens the cracker.

Caesar cipher chart

A shift-3 Caesar cipher wheel, the full alphabet and how to crack the code.

How to encode a Caesar cipher by hand

Number the letters from A = 0 to Z = 25. To encode, add the shift to each letter’s number; if the total is 26 or more, subtract 26. Then turn the number back into a letter. Here is MEET ME AT NOON with a shift of 3, one row per different letter:

Plain letterNumber+ 3Cipher letter
M1215P
E47H
T1922W
A03D
N1316Q
O1417R

So MEET ME AT NOON becomes PHHW PH DW QRRQ. Notice that both E’s turn into the same letter and the double O stays a double letter: a Caesar cipher keeps the shape of every word, which is exactly what makes it easy to attack.

Wrapping around. With a shift of 5, Z is letter 25, and 25 + 5 = 30. Take away 26 and you get 4, which is E. The word ZOO becomes ETT. Mathematicians write the rule as C = (P + k) mod 26, where P is the plain letter’s number and k is the shift.

How to decode a Caesar cipher with the key

Decoding is the same process run backward: subtract the shift instead of adding it, and add 26 whenever the result drops below 0. The rule is P = (C − k) mod 26. Shifting back by k is the same as shifting forward by 26 − k, so a message encoded with shift 7 is decoded by shifting it forward 19.

Example: with a shift of 7, the message Aol aylhzbyl pz bukly aol aopyk zalw decodes to The treasure is under the third step. Try it: choose Decode, set the shift to 7 and paste the code into the box.

A handy check: encoding with a shift and decoding with the same shift must give you back exactly what you started with. If you are not sure which way a puzzle maker shifted, decoding with shift k and encoding with shift 26 − k are the same thing, so try both directions before deciding the key is wrong.

Caesar cipher examples

The same phrase, Hello World, at a few different shifts. Capital letters stay capital and the space stays where it is:

ShiftEncoded
1Ifmmp Xpsme
3Khoor Zruog
5Mjqqt Btwqi
10Rovvy Gybvn
13Uryyb Jbeyq
20Byffi Qilfx
25Gdkkn Vnqkc

Shift 25 moves every letter one place back, so it undoes shift 1. Shift 13 is the only shift that is its own opposite, which is why it gets a name of its own, ROT13.

Caesar cipher alphabet (shift 3)

If you are working on paper, write the alphabet twice, one line above the other, with the bottom line moved along by the shift. This is the table for the classic shift of 3:

PlainABCDEFGHIJKLM
CipherDEFGHIJKLMNOP
PlainNOPQRSTUVWXYZ
CipherQRSTUVWXYZABC

Find the plain letter in a Plain row; its cipher letter is directly below it. To decode, find the letter in a Cipher row and read the plain letter above it.

Caesar cipher table: all 25 shifts

Each row shows what A to Z turn into for one shift. To encode, find the plain letter’s position (A is the first letter of the row, B the second, and so on). To decode with a known shift, find the cipher letter in that row and count which position it is in.

ShiftA B C … Z become
1BCDEFGHIJKLMNOPQRSTUVWXYZA
2CDEFGHIJKLMNOPQRSTUVWXYZAB
3 (classic)DEFGHIJKLMNOPQRSTUVWXYZABC
4EFGHIJKLMNOPQRSTUVWXYZABCD
5FGHIJKLMNOPQRSTUVWXYZABCDE
6GHIJKLMNOPQRSTUVWXYZABCDEF
7HIJKLMNOPQRSTUVWXYZABCDEFG
8IJKLMNOPQRSTUVWXYZABCDEFGH
9JKLMNOPQRSTUVWXYZABCDEFGHI
10KLMNOPQRSTUVWXYZABCDEFGHIJ
11LMNOPQRSTUVWXYZABCDEFGHIJK
12MNOPQRSTUVWXYZABCDEFGHIJKL
13 (ROT13)NOPQRSTUVWXYZABCDEFGHIJKLM
14OPQRSTUVWXYZABCDEFGHIJKLMN
15PQRSTUVWXYZABCDEFGHIJKLMNO
16QRSTUVWXYZABCDEFGHIJKLMNOP
17RSTUVWXYZABCDEFGHIJKLMNOPQ
18STUVWXYZABCDEFGHIJKLMNOPQR
19TUVWXYZABCDEFGHIJKLMNOPQRS
20UVWXYZABCDEFGHIJKLMNOPQRST
21VWXYZABCDEFGHIJKLMNOPQRSTU
22WXYZABCDEFGHIJKLMNOPQRSTUV
23XYZABCDEFGHIJKLMNOPQRSTUVW
24YZABCDEFGHIJKLMNOPQRSTUVWX
25ZABCDEFGHIJKLMNOPQRSTUVWXY

The Caesar cipher wheel

ABCDEFGHIJKLMNOPQRSTUVWXYZDEFGHIJKLMNOPQRSTUVWXYZABCoutside: plaininside: ciphershift 3
A cipher wheel at shift 3: plain letters on the outer ring, cipher letters on the inner ring.

A cipher wheel (or cipher disk) is two alphabet rings, one inside the other, that can turn. Line up the inner A under the outer letter your shift points to, then read across: every plain letter on the outside sits next to its cipher letter on the inside. You can make one with two paper circles of different sizes, each with the 26 letters spaced evenly around the edge, and a brass fastener through the middle. The Step by step section of the tool above draws the wheel for whatever shift you choose.

How to crack a Caesar cipher without the key

There are only 25 possible shifts, so the surest attack is to try them all. This is called a brute force attack, and with a sentence or more only one shift produces English. Here is the message Mctyr esp xla ez esp wtmclcj lqepc wfyns run through the tool’s cracker. These are its five best guesses out of 25:

RankShiftReadingReal words
111Bring the map to the library after lunch100%
224Oevat gur znc gb gur yvoenel nsgre yhapu0%
320Sizex kyv drg kf kyv czsirip rwkvi clety0%
44Iypun aol thw av aol spiyhyf hmaly sbujo0%
55Hxotm znk sgv zu znk rohxgxe glzkx ratin0%

The true shift, 11, comes out at rank 1, and it is the only reading in which every word is a real word. The ranking adds two things together: how common each three-letter sequence in the result is in English (TH, ING and ER sequences score well, QZX does not), and how many of the words are in our dictionary. Open Crack it in the tool to see the same ranking for your own message.

By hand, you can do the same with a short word. Take the first word of the code and write the 25 shifts of just that word in a column; usually only one or two are real words, and you check those against the rest of the message. A single-letter word is a gift: in English it is almost always A or I, so it leaves only two possible shifts.

Frequency analysis

For a longer message there is a faster trick. Letters are not equally common in English, and a Caesar shift moves the whole pattern along without changing its shape. Count the letters of the code, find the most common one, and assume it stands for E. These are the twelve most common letters in English, counted from the 21,435 most common words in our own dictionary:

LetterEIANTROSLCDU
Share11.9%8.8%7.6%7.6%7.4%7.2%6.1%6.1%5.5%4.4%4.2%3.4%

(Counted over a word list rather than running text, T and H come out lower than in an ordinary paragraph, where the word “the” repeats constantly; E is on top either way.)

A 231-letter message about a kite festival, encoded with a shift we will pretend not to know, has these most common letters: O (30 times), D (24 times), C (18 times). If O stands for E, the shift is 10, and shifting back by 10 gives readable English straight away: “Every summer our town holds a kite festival on…”. That is one guess instead of 25, and on a long message it works almost every time.

Why the Caesar cipher is easy to break

A good cipher needs far more possible keys than anyone could ever try, and it should hide the patterns of the language. The Caesar cipher fails at both. It has only 25 keys, so a person with a pencil can try every one in a few minutes and a computer does it instantly. And because each letter always becomes the same cipher letter, every pattern survives: double letters stay double, a three-letter word that appears again and again is probably THE, and the most common cipher letter is probably E.

Later ciphers attacked these weaknesses one at a time. A mixed alphabet gives an enormous number of keys but still keeps the letter patterns; a keyword cipher such as Vigenère changes the shift from letter to letter, which flattens the patterns:

CipherPossible keysHow it is broken
ROT131No key at all: apply it again
Atbash1No key at all: apply it again
Caesar25Try every shift, or frequency analysis
Affine312 (12 × 26)Try every key, or solve from two known letters
Simple substitution403,291,461,126,605,635,584,000,000 (26 × 25 × … × 1)Frequency analysis and word patterns
Vigenère26 for every letter of the keywordFind the keyword length, then crack each column like a Caesar cipher

Variations: ROT13, keyed Caesar and more

  • ROT13 is a Caesar cipher with a shift of 13. Because 13 is half of 26, encoding and decoding are the same step. It has its own ROT13 tool, which also handles ROT5 for digits and ROT47.
  • Keyed Caesar. First write a keyword without repeated letters, then the rest of the alphabet: PLANET gives PLANETBCDFGHIJKMOQRSUVWXYZ. Then shift that alphabet as usual; with a shift of 4 it becomes ETBCDFGHIJKMOQRSUVWXYZPLAN. Plain A to Z map onto that line. Paste the line into the Substitution Cipher tool to use it.
  • Atbash reverses the alphabet instead of shifting it (A↔Z, B↔Y). See the Atbash cipher.
  • Affine cipher multiplies before it shifts, which gives 312 keys instead of 25. A Caesar shift is the affine cipher with a = 1. See the Affine cipher.
  • Vigenère cipher uses a different Caesar shift for each letter, taken from a keyword. That one change made it far harder to break. See the Vigenère cipher.

Caesar cipher in Python

The rule fits in a few lines of code. This function shifts letters and leaves everything else alone; pass a negative shift to decode.

def caesar(text, shift):
    out = []
    for ch in text:
        if ch.isupper():
            out.append(chr((ord(ch) - 65 + shift) % 26 + 65))
        elif ch.islower():
            out.append(chr((ord(ch) - 97 + shift) % 26 + 97))
        else:
            out.append(ch)
    return "".join(out)

print(caesar("Hello World", 3))   # Khoor Zruog
print(caesar("Khoor Zruog", -3))  # Hello World

Python’s % operator always returns a number from 0 to 25 here, even for negative shifts, so the wrap-around takes care of itself.

Caesar cipher practice puzzles

Solve these on paper first, then check your answer with the decoder above.

Puzzle 1 (Easy)

Shift 1: every letter moved one place.

TFF ZPV BU UIF QBSL

Show the answer

SEE YOU AT THE PARK (shift 1)

Puzzle 2 (Medium)

The classic shift of 3.

WKH FDNH LV LQ WKH EOXH ERA

Show the answer

THE CAKE IS IN THE BLUE BOX (shift 3)

Puzzle 3 (Hard)

Shift unknown. Look for a short word that could be THE or AND.

TLD MAX HPE TM MAX ZTMX YHK MAX ITLLPHKW

Show the answer

ASK THE OWL AT THE GATE FOR THE PASSWORD (shift 19)

History of the Caesar cipher

The cipher is named after Julius Caesar because the Roman historian Suetonius, writing in his Lives of the Caesars, says that Caesar wrote private messages in which each letter was replaced by the one three places further on, so that D stood for A. Suetonius also describes Caesar’s successor Augustus using a shift of one, writing B for A. The method is far older in spirit than its name: replacing letters by a fixed rule is one of the oldest ideas in secret writing.

Against readers who did not know the trick, it may have worked well enough. Against anyone who suspects a shift, it never stood a chance: the Arab scholar al-Kindi described frequency analysis in the ninth century, and that method breaks every Caesar cipher of a reasonable length. Today the Caesar cipher is used for puzzles and teaching, never for real secrets.

Tips for using Caesar ciphers in puzzles

  • Hide the word lengths. Remove the spaces, or split the code into groups of five letters, so solvers cannot spot THE, AND or A.
  • Give a hint, not the key. A clock showing four o’clock, or “count the candles on the cake”, is more fun than “shift 4”.
  • Avoid shift 13 for beginners if you also want them to learn ROT13 later, and avoid shift 0 or 26, which do nothing.
  • Combine it. A Caesar shift on top of Morse code or A1Z26 numbers makes a two-step puzzle for older players.

Free and private

This Caesar cipher tool runs entirely in your browser: free, with no sign-up, and nothing you type is uploaded or stored. Links to other decoders put your text after a # in the address, which browsers never send to a server.

For teachers, bloggers & clubs

Put the Caesar Cipher on your website

Give your readers this tool right on your page. Copy the code, paste it into your site, done: no sign-up, no account.

  • Free for any website
  • No ads, no cookies
  • Fits phones and sidebars
  • Always up to date
See it live ↗

Please keep the small credit line under the tool; you may add rel="nofollow" to its link. How it works & the rules

› Show the code

Frequently asked questions

What is the Caesar cipher?
The Caesar cipher replaces every letter with the letter a fixed number of places further along the alphabet, wrapping from Z back to A. With a shift of 3, A becomes D and HELLO becomes KHOOR.
How do I decode a Caesar cipher?
Shift every letter back by the same number used to encode it. In the tool, choose Decode, set the shift and paste the message. If you do not know the shift, open Crack it: the tool tries all 25 shifts and puts the one that reads as English at the top.
How do you solve a Caesar cipher without the key?
Try all 25 shifts and keep the one that gives real words, or count the letters and assume the most common one stands for E. With a sentence or more, only one shift reads as English.
What shift did Julius Caesar use?
According to the Roman historian Suetonius, Caesar used a shift of three, so that D stood for A. That is why 3 is the default shift.
How many keys does a Caesar cipher have?
Only 25 useful ones, the shifts 1 to 25. A shift of 26 (or 0) leaves the text unchanged. That tiny number is why the cipher is so easy to break.
What is the difference between the Caesar cipher and ROT13?
ROT13 is a Caesar cipher with a fixed shift of 13. Because 13 is half of 26, applying it twice gives back the original, so the same step encodes and decodes.
What is a Caesar cipher wheel?
Two alphabet rings, one inside the other, that turn. Line up the inner ring at your shift and every plain letter on the outside sits next to its cipher letter. The Step by step section of the tool draws one for any shift.
Does the Caesar cipher change numbers and punctuation?
No. Only the 26 letters A to Z are shifted. Digits, spaces and punctuation stay as they are, and capital and small letters keep their case.
Is the Caesar cipher a substitution cipher?
Yes. It is the simplest kind of substitution cipher: each letter is always replaced by the same other letter, and the replacement alphabet is just the normal alphabet moved along.
Is my text private?
Yes. The tool runs entirely in your browser and nothing you type is uploaded or stored.

About this page

The Caesar Cipher is a free tool from Linguaholic, made by Marcel Iseli. It runs in your browser, with no sign-up. Last updated .

The code breaker's English letter frequencies and word checks come from Linguaholic’s English dictionary, built from the open ENABLE and SCOWL word lists. Licenses and notices.

Keep exploring

Browse all 99 tools