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.

Shift cipher decoder and solver

A shift cipher is any code that moves every letter the same number of places along the alphabet. The Caesar cipher is the best known shift cipher (Caesar himself used a shift of 3), and ROT13 is the shift cipher with a shift of 13. So this page works as a shift cipher decoder, a shift cipher encoder and a shift cipher solver in one, for every shift from 1 to 25.

  • You know the shift: use it as a Caesar cipher decoder. Choose Decode, set the shift and paste the message.
  • You do not know the shift: open Crack it. The shift cipher solver tries all 25 shifts, ranks them by how much they read like English, and puts the answer at the top.
  • The puzzle says “shift left”: a shift to the left is the same as decoding. To encode with a left shift, use the right shift that makes up 26 with it:
Left shifts and the right shift that gives the same result
Shift left bySame as shift right byA becomes
125Z
224Y
323X
422W
521V
1016Q

Try the solver on these

Each message below uses a different shift that we do not tell you. Tap Solve it to let the tool find it:

Shift cipher messages to solve with the tool
Coded messageSolve it
Vgiq g zuxin gtj skkz he znk urj ugq zxkkSolve it: open “Vgiq g zuxin gtj skkz he znk urj ugq zxkk” in the shift cipher solver
Kyv rejnvi zj yzuuve leuvi kyv pvccfn drkSolve it: open “Kyv rejnvi zj yzuuve leuvi kyv pvccfn drk” in the shift cipher solver
Sahh zkja ukq bkqjz pda hwop yhqaSolve it: open “Sahh zkja ukq bkqjz pda hwop yhqa” in the shift cipher solver

The solver needs a few words to be sure. With only one or two short words, several shifts can make real words, so the tool shows all 25 and you pick the one that fits the puzzle.

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.

Printable cipher wheel for classrooms

Make your own Caesar cipher wheel (also called a cipher disk) from one sheet of paper. Turn the wheel below to see how it works, then print it: you get a large outer disk with the plain alphabet, a smaller inner disk with the code alphabet and the numbers 0 to 25, a 5 cm scale bar, and short instructions.

ABCDEFGHIJKLMNOPQRSTUVWXYZOUTER DISK: plain lettersA0B1C2D3E4F5G6H7I8J9K10L11M12N13O14P15Q16R17S18T19U20V21W22X23Y24Z25INNER DISK: code letters

Turn the inner disk to try it. At shift 3, the outer A sits on the inner D, so A becomes D, B becomes E and Z becomes C.

shift 3
Printable wheel

One page, US Letter or A4. Print at 100% so the disks come out 14 cm and 10.4 cm across.

  1. Print at real size. In the print window choose 100% or “Actual size” (not “Fit to page”). The scale bar on the sheet should measure 5 cm. US Letter and A4 both work.
  2. Cut out both disks along the outer black lines. For a wheel that lasts all year, glue the page onto thin card or a cereal box first.
  3. Join them in the middle. Make a small hole at each + mark with a pencil tip, lay the small disk on the big one, and push a paper fastener (brad) through both. A pin and an eraser, or a dab of sticky tack, also work.
  4. Set the shift. Turn the small disk until its arrow, next to A, points at the outer letter for your shift: D for shift 3, K for shift 10. The small number under the outer A is the shift too.
  5. Encode and decode. To encode, find each message letter on the outside and write the letter just inside it. To decode, go the other way: from the inside out.

Classroom ideas: give pairs of students one wheel each and a secret shift, let them swap coded notes, then hand out a message without the shift and ask them to crack it by turning the wheel through all 25 positions. The blank version, with an empty inner disk, lets older students write their own scrambled alphabet, which turns the Caesar wheel into a substitution cipher wheel.

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 "A" <= ch <= "Z":
            out.append(chr((ord(ch) - 65 + shift) % 26 + 65))
        elif "a" <= ch <= "z":
            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.
What is a shift cipher?
A shift cipher moves every letter the same number of places along the alphabet, wrapping from Z back to A. The Caesar cipher is the best known shift cipher, with a shift of 3, and ROT13 is the shift cipher with a shift of 13. This tool encodes, decodes and solves shift ciphers for every shift from 1 to 25.
How do I use the shift cipher solver?
Choose Decode, paste the coded message and open Crack it. The solver tries all 25 shifts, ranks them by how much they read like English, and puts the answer at the top. Press Use shift to apply it. With only one or two short words, check the other high-ranked shifts too.
How do I decode a Caesar cipher that shifts to the left?
A left shift is the same as a right shift of 26 minus that number: shift 3 to the left equals shift 23 to the right, so A becomes X. To read a message written with a left shift, encode it with the same number; to read a right-shift message, decode it.
Is there a printable cipher wheel?
Yes. The Printable cipher wheel section on this page prints a cipher disk on one sheet of US Letter or A4: an outer disk with the plain alphabet, an inner disk with the code alphabet and the numbers 0 to 25, a 5 cm scale bar and instructions. Print at 100%, cut out both disks and join them with a paper fastener. A blank inner disk is available for students to write their own alphabet.
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 118 tools