Skip to content

↑↓ navigate ↵ open Esc close Search runs locally

Caesar Cipher: Encoder, Decoder & Solver

Encrypt or decrypt text with any Caesar shift, or paste a message and let the solver try every shift and pick the one that reads like English.

  • Runs in your browser
  • Nothing is uploaded
  • Free, no sign-up
0 chars
Caesar cipher
Runs in your browser. Nothing is uploaded. Tip: Decrypt shows every shift and the most likely one

How to use the Caesar cipher tool#

  1. Choose Encrypt to hide a message or Decrypt to read one.
  2. Set the Shift (the key). Julius Caesar used 3; ROT13 is a shift of 13.
  3. Don't know the shift? Choose Decrypt and look at All shifts under the tool: every possible shift is listed, and the most English-looking one is highlighted. Click a row to use it.
  4. Switch the Alphabet to Printable ASCII to also shift digits and symbols, then copy the result.

Examples#

Encrypt with Caesar's own shift of 3

Input
attack at dawn
Output
dwwdfn dw gdzq

Each letter moves 3 places forward: a → d, t → w, w → z.

Decrypt with a known shift

Input
Wkh txlfn eurzq ira
Output
The quick brown fox

Decrypting moves each letter back by the shift.

Crack a message without the key

Input
Brx fdq ghfrgh wklv phvvdjh zlwkrxw nqrzlqj wkh nhb
Output
You can decode this message without knowing the key

The All shifts list ranks every shift by how English it looks and marks shift 3 as the most likely.

What is the Caesar cipher?#

The Caesar cipher replaces each letter with the letter a fixed number of positions further along the alphabet, wrapping around from Z to A. That number is the shift, or key. With a shift of 3, A becomes D, B becomes E and Z becomes C. To decrypt, shift back by the same amount.

It is named after Julius Caesar, who, according to the Roman historian Suetonius, used a shift of 3 for his private letters. It is one of the oldest known ciphers and the classic starting point for learning cryptography.

How it works#

Number the letters from 0 (A) to 25 (Z). With a shift n:

plaintext
encrypt:  E(x) = (x + n) mod 26decrypt:  D(x) = (x − n) mod 26
PlainABCDE…WXYZ
Shift 3DEFGH…ZABC

Letter case is kept, and spaces, digits and punctuation are not changed. With the Printable ASCII alphabet in this tool, the same idea is applied to all 94 characters from ! to ~, so digits and symbols are shifted too.

Caesar cipher, ROT13 and ROT-N#

"ROT-N" is another name for a Caesar shift of N. ROT13 is the Caesar cipher with a shift of 13. It is special because 13 is half of 26: encrypting twice gets you back to the start, so the same operation encrypts and decrypts. ROT47 is the same idea applied to 94 ASCII characters with a shift of 47.

How to break a Caesar cipher#

A Caesar cipher has only 25 useful keys, so it can always be broken, even without the key. There are two classic methods, and this tool uses both:

  1. Brute force: try every shift from 1 to 25 and look for the one that produces readable text. The All shifts list does exactly this.
  2. Frequency analysis: in English, E, T, A and O are the most common letters, and Z, Q and X are rare. A shift keeps those proportions, just moved along the alphabet. The solver compares the letter frequencies of each candidate with typical English using a chi-squared test and marks the closest match as the most likely shift.

Frequency analysis needs enough text to work. Very short messages (a word or two) can produce several plausible answers, so check the list yourself. It also assumes English: for other languages, the brute-force list is still correct, but the highlighted guess may not be.

The Caesar cipher offers no real security. With only 25 possible keys, anyone can break it in seconds, as this page shows. Use it for puzzles, games and teaching, never for real secrets.

Caesar cipher in code#

JavaScript#

javascript
function caesar(text, shift) {  const k = ((shift % 26) + 26) % 26; // also works for negative shifts (decrypt)  return text.replace(/[a-z]/gi, (c) => {    const base = c <= 'Z' ? 65 : 97;    return String.fromCharCode(((c.charCodeAt(0) - base + k) % 26) + base);  });} caesar('attack at dawn', 3);   // "dwwdfn dw gdzq"caesar('dwwdfn dw gdzq', -3);  // "attack at dawn"

Python#

python
def caesar(text: str, shift: int) -> str:    out = []    for c in text:        if c.isascii() and c.isalpha():            base = ord('A') if c.isupper() else ord('a')            out.append(chr((ord(c) - base + shift) % 26 + base))        else:            out.append(c)    return ''.join(out) # Brute force: print every possible decryptionfor k in range(1, 26):    print(k, caesar('dwwdfn dw gdzq', -k))

Common errors and fixes#

  • The decrypted text is still unreadable

    The shift is wrong, or the text is not a Caesar cipher. Switch to Decrypt and read the All shifts list. If no row is readable, the message may use a different cipher, such as Vigenère or a substitution cipher.

  • The solver picked the wrong shift

    The message is probably too short or not in English, so letter frequencies are unreliable. Scan the full list of 25 shifts and click the readable one.

  • Digits and symbols were not shifted

    The Letters alphabet only shifts A–Z. Choose Printable ASCII to shift every character from ! to ~.

  • Decrypting with the same shift gives garbage

    Make sure you chose Decrypt, which shifts backwards. Encrypting again with the same shift moves the letters further instead (except for a shift of 13, which is self-inverse).

Frequently asked questions#

How do I decrypt a Caesar cipher without the key?

Choose Decrypt and paste the message. The tool lists all 25 possible shifts and highlights the one whose letter frequencies are closest to English. Click any row to use that shift.

What shift did Julius Caesar use?

A shift of 3, according to Suetonius: each letter was replaced by the one three places later, so A became D.

How many keys does a Caesar cipher have?

25 useful ones. A shift of 0 or 26 leaves the text unchanged, so there are only 25 different encryptions of any message, which is why it is so easy to break.

Is ROT13 the same as a Caesar cipher?

ROT13 is a Caesar cipher with a shift of 13. It is the only shift that is its own inverse in the 26-letter alphabet.

Does the Caesar cipher change numbers and punctuation?

Not in the classic version, which only shifts letters. Choose the Printable ASCII alphabet in this tool to shift digits and symbols as well.

Is my text uploaded?

No. Encryption, decryption and the solver all run in your browser.

Your next tool is one search away.

Free, private developer tools that run in your browser. No signup, nothing uploaded, no waiting.

Browse all tools

Tip: press Ctrl D to bookmark dev247.