Skip to main content
PixelTools
All articles
Tutorials4 min readby the PixelTools team

How to Decode a Caesar Cipher (Any Shift)

To decode a Caesar cipher, shift each letter back by the key. No key? Try all 25 shifts or match the most common letter to E. Worked example included.

The short answer: move every letter back by the shift

To decode a Caesar cipher, move each letter backward through the alphabet by the shift the sender used. If the shift was 3, then D becomes A, E becomes B, and A wraps around to X. Leave spaces, digits and punctuation alone. So Khoor, Zruog! decodes with shift 3 to Hello, World! If you do not know the shift, you have two options: try all 25 possible shifts and keep the one that reads as English, or count letters and assume the most common one stands for E. Both are practical on a short message, because a Caesar cipher only has 25 usable keys. The next sections cover each case, then check the answer in a free browser tool.

When you know the shift: count back

With a known shift, decoding is mechanical. Write the alphabet on a strip of paper, then for each ciphertext letter count backward by the shift. With shift 3, K counts back to H, h to e, o to l, and r to o, so Khoor becomes Hello. The one trap is the wrap: counting back from A, B or C passes the start of the alphabet and continues from Z, so with shift 3 the letter A decodes to X. Case is preserved, so a capital stays a capital, and Z in Zruog simply counts back to W. Decoding with shift 3 gives the same result as encoding with shift 23, because the two add up to 26. Check by re-encoding your answer with the original shift.

When you do not know the shift: try all 25

Brute force means decoding the message with every shift from 1 to 25 and reading down the list until one line is English. Shift 0 and shift 26 change nothing, so 25 attempts is the full search. Take the ciphertext Vnnc vn jc cqn xum karmpn jc wxxw. Run it through every shift and you get Ummb um ib bpm wtl jzqlom ib vwwv at shift 1, Tlla tl ha aol vsk at shift 2, and so on. Only one line is readable: shift 9 gives Meet me at the old bridge at noon. We computed all 25 lines with code to confirm there is exactly one readable result. Scan the short words first, since a one-letter word is usually A or I and a three-letter word is often THE.

A faster way: match the most common letter to E

Letter frequency avoids checking all 25 shifts. E is the most common letter in English, so tally the ciphertext letters and assume the top one stands for E. Then the shift is the distance from E to that letter. In Vnnc vn jc cqn xum karmpn jc wxxw, the letter n appears 5 times, more than any other. Counting from E forward to N is 9 steps, so the shift is 9, which matches the brute-force result. Frequency analysis needs enough text to be reliable. On a very short message, a different letter can win the tally, such as T, A or O. If your first guess gives nonsense, try the second most common letter as E and check again.

Decoding in the PixelTools Caesar tool

The tool opens in Encode mode with the shift set to 3, so to decode you must switch the toggle to Decode first. If you skip that step, shift 3 on Khoor, Zruog! gives Nkrru, Cuxrj! instead of Hello, World! The slider runs from 1 to 25 and the result updates as you type. Only A to Z and a to z are shifted. Accented letters pass through untouched, so Café with shift 1 becomes Dbgé, with the é left as it was. The tool has no all-shifts list and no auto-detect, and it never shows an error message, since any text is valid input. To brute force, drag the slider from 1 upward and watch the output. The swap button moves the output into the input and flips the mode.

Common mistakes when decoding

The most common mistake is shifting the wrong way. Encoding adds the shift and decoding subtracts it, so applying the key in the same direction gives gibberish. The second is counting the starting letter as step one, which lands you one letter off. Third, people forget the wrap at the end of the alphabet. Fourth, a message that stays unreadable at all 25 shifts probably is not a Caesar cipher. Check whether the spaces were removed, or whether it is a different cipher such as Atbash, which reverses the alphabet, or Vigenere, which uses a keyword. ROT13 is a Caesar cipher with shift 13, so one pass encodes it and a second pass decodes it.

Frequently asked questions

Try it on PixelTools — free, no upload needed