decoder.tools

Caesar Cipher Decoder

Decode a Caesar shift cipher without knowing the key. All 25 shifts are tried and the most English-looking one is highlighted.

INPUT
OUTPUT

The result appears here as you type.

Decoding runs in your browser. What you paste is not sent to a server.

A Caesar cipher decoder recovers text that was encrypted by shifting every letter a fixed number of places in the alphabet. There are only 25 possible shifts, so the decoder simply tries them all and picks the one that reads like English.

Example

Input
Wkh txlfn eurzq ira mxpsv ryhu wkh odcb grj
Output
ROT23  The quick brown fox jumps over the lazy dog
Best guess: ROT23 (encoded with a shift of 3)

The tool lists all 25 candidates. The best guess comes from comparing each one with English letter frequencies, so it is reliable for a sentence but can miss on a single short word. Scan the list in that case.

How the Caesar cipher works

Each letter is replaced by the letter k positions further along, wrapping from Z back to A. With a shift of 3 (the one Julius Caesar reportedly used), A becomes D, B becomes E and Z becomes C:

PlainABC…XYZ
Shift 3DEF…ABC

As formulas, with letters numbered 0–25: encryption is E(x) = (x + k) mod 26, decryption is D(x) = (x − k) mod 26. Decrypting a shift of 3 is the same as shifting forward by 23, which is why the answer above appears on the ROT23 line.

ROT13 is the special case k = 13.

How to recognize a Caesar cipher

  • Only letters change. Spaces, punctuation, digits and word lengths stay the same.
  • Letter frequencies look like English, just moved. The most common ciphertext letter is often E shifted.
  • A three-letter word that repeats a lot is probably the, and that tells you the shift directly: wkh means a shift of 3.

How to use the Caesar cipher decoder

  1. Paste the ciphertext.
  2. Read the Best guess line, then find that shift in the list.
  3. For very short messages, scan all 25 lines for the readable one.

Brute-force a Caesar cipher in code

Python
def shift(text, k):
    return "".join(
        chr((ord(c) - b + k) % 26 + b) if c.isalpha() else c
        for c in text
        for b in [65 if c.isupper() else 97]
    )

for k in range(1, 26):
    print(k, shift("Wkh txlfn eurzq ira", k))

At a glance

TypeMonoalphabetic substitution (shift)
Key space25 useful shifts
Decrypt shift kShift forward by 26 − k
Broken byBrute force or frequency analysis, instantly

Frequently asked questions

How do I decode a Caesar cipher without the key?

Try all 25 shifts and pick the one that makes sense. That's what this tool does, and the English-frequency ranking usually picks it for you.

Why does the answer appear on a different number than the shift?

The list shows how far each line was shifted forward. Undoing a shift of 3 means shifting forward by 23, so text encoded with shift 3 is readable on the ROT23 line. The best-guess field gives both numbers.

What if none of the 25 lines is readable?

It isn't a simple Caesar cipher. If letters repeat with the same word lengths, try Atbash. If the same letter encrypts differently in different places, it's probably Vigenère. If it's only A and B, try Baconian.

Does it work for other languages?

The shifting works on any text in the 26-letter Latin alphabet, and the readable line will still be in the list. The best-guess ranking uses English letter frequencies, so it is less reliable for other languages.

Last reviewed · found a mistake? contact@decoder.tools · view as markdown