Caesar Cipher Decoder

Caesar Cipher Decoder

0 characters
0 characters

Letter key

Bars show how often each letter appears in your message. Lines mark normal English.

Cipher wheel
3Shift

Drag the inner ring to turn it. Outer ring: plain letters. Inner ring: coded letters.

Every possible shift

Paste a message above to see all 26 readings, most likely first.

    Shortcuts: Alt + ↑ / ↓ changes the shift, Ctrl + Enter runs when Live is off. Everything happens in your browser. Your text is never uploaded.

    A Caesar cipher decoder, or Caesar cipher translator, turns a shifted message back into plain text. Paste the ciphertext and the decoder moves every letter back by the shift value. Don't know the shift? The solver tries all 25 keys and ranks them by how much each result looks like English.

    1. Shift controlSlider, number box, presets and wheel
    2. Input boxPaste ciphertext or plaintext
    3. Output boxUpdates as you type
    4. Letter keyEach plain letter above its coded letter
    5. Ranked shiftsAll 26 shifts, best match first

    What Is the Caesar Cipher?

    The Caesar cipher is a substitution cipher that replaces each letter with the letter a fixed number of positions further along the alphabet. That number is the key, called the shift value. With a shift of 3, A becomes D, B becomes E, and Z wraps around to C.

    Cipher type
    Substitution
    Possible keys
    25
    Classic shift
    3
    First used
    1st century BC

    The Caesar cipher is one of the oldest known ciphers in cryptography. It takes its name from Julius Caesar, the Roman general who used it in his private letters. Other names for it:

    Caesar shiftCaesar codeShift cipherCaesar cipher translator

    How to Use the Caesar Cipher Decoder

    To use the Caesar cipher decoder, pick a task below. The result updates as you type.

    Key known

    Decode with a Known Shift

    1. Select Decode.
    2. Paste the ciphertext.
    3. Set the shift with the slider, buttons or wheel.
    4. Copy the plaintext.
    Key unknown

    Decode without the Key

    1. Leave Auto-detect on.
    2. Paste the ciphertext.
    3. Read the result and its likelihood score.
    4. Open "Show all 26 shifts" and click a row if the result looks wrong.
    Hide a message

    Encode a Message

    1. Select Encode.
    2. Type your plaintext.
    3. Set the shift and share it with the reader.
    4. Copy the ciphertext or a share link.

    Alphabet, Case and Spacing Options

    The decoder has 4 settings:

    Live

    OnOff

    Updates on every keystroke. Turn it off and press Run, or Ctrl + Enter, for long texts.

    Alphabet

    A to ZA to Z + 0 to 9Custom

    Sets which characters shift: 26 letters, 36 characters or your own alphabet.

    Letter case

    KeepABCabc

    Keeps the original case, or converts the output to uppercase or lowercase.

    Spaces and punctuation

    Keep allSpaces onlyRemove

    Keeps every character, keeps spaces only, or outputs letters only.

    How the Caesar Cipher Works

    The Caesar cipher moves every letter of the plaintext the same number of places along the alphabet. Letters past Z wrap back to A. Spaces, digits and symbols stay unchanged in the standard version.

    1. 1Number the letterX = 23
    2. 2Add the shift23 + 3 = 26
    3. 3Wrap with mod 2626 → 0 = A

    The Caesar Cipher Formula

    The Caesar cipher formula is E(x) = (x + n) mod 26 for encryption and D(x) = (x − n) mod 26 for decryption.

    Encrypt E(x) = (x + n) mod 26Decrypt D(x) = (x − n) mod 26
    x
    Letter position: A = 0, B = 1, up to Z = 25
    n
    Shift value, from 0 to 25
    mod 26
    Keeps the remainder after dividing by 26 (modulo)
    Encrypt

    X (23) + 3 = 2626 mod 26 = 0X becomes A

    Decrypt

    C (2) − 3 = −1−1 + 26 = 25C becomes Z

    Try the formula

    X = 23+ 3 =26mod 26 =0→A

    Example: HELLO WORLD with Shift 3

    HELLO WORLD with a shift of 3 becomes KHOOR ZRUOG. To decode it, move each letter 3 places back. Type your own word or move the shift:

    PlaintextHELLOWORLD
    Shift 3KHOORZRUOG

    The Caesar Cipher Wheel

    A Caesar cipher wheel is 2 alphabet rings, one inside the other. Turn the inner ring by the shift value, and each outer letter sits next to its coded letter. Decoder rings and classroom cipher disks use the same design. The wheel in this tool turns as you change the shift.

    Caesar Cipher Chart: All 25 Shifts

    The Caesar cipher chart lists the coded alphabet for each of the 25 shifts. To encode, read each plain letter (A to Z) against the letter below it in your shift's row. To decode, go the other way. Press "Use" to load a shift into the decoder.

    ShiftA becomesABCDEFGHIJKLMNOPQRSTUVWXYZLoad
    1BBCDEFGHIJKLMNOPQRSTUVWXYZA
    2CCDEFGHIJKLMNOPQRSTUVWXYZAB
    3CaesarDDEFGHIJKLMNOPQRSTUVWXYZABC
    4EEFGHIJKLMNOPQRSTUVWXYZABCD
    5FFGHIJKLMNOPQRSTUVWXYZABCDE
    6GGHIJKLMNOPQRSTUVWXYZABCDEF
    7HHIJKLMNOPQRSTUVWXYZABCDEFG
    8IIJKLMNOPQRSTUVWXYZABCDEFGH
    9JJKLMNOPQRSTUVWXYZABCDEFGHI
    10KKLMNOPQRSTUVWXYZABCDEFGHIJ
    11LLMNOPQRSTUVWXYZABCDEFGHIJK
    12MMNOPQRSTUVWXYZABCDEFGHIJKL
    13ROT13NNOPQRSTUVWXYZABCDEFGHIJKLM
    14OOPQRSTUVWXYZABCDEFGHIJKLMN
    15PPQRSTUVWXYZABCDEFGHIJKLMNO
    16QQRSTUVWXYZABCDEFGHIJKLMNOP
    17RRSTUVWXYZABCDEFGHIJKLMNOPQ
    18SSTUVWXYZABCDEFGHIJKLMNOPQR
    19TTUVWXYZABCDEFGHIJKLMNOPQRS
    20UUVWXYZABCDEFGHIJKLMNOPQRST
    21VVWXYZABCDEFGHIJKLMNOPQRSTU
    22WWXYZABCDEFGHIJKLMNOPQRSTUV
    23XXYZABCDEFGHIJKLMNOPQRSTUVW
    24YYZABCDEFGHIJKLMNOPQRSTUVWX
    25ZZABCDEFGHIJKLMNOPQRSTUVWXY

    How to Decode a Caesar Cipher without the Key

    To decode a Caesar cipher without the key, use 1 of 3 cryptanalysis methods:

    Brute Force

    Brute force means trying all 25 shifts and picking the one that reads as real words. A person tests every shift by hand in about 10 minutes. A computer does it in under a millisecond. Move the slider to try it on WKH TXLFN EURZQ IRA:

    Try brute force by hand

    WKH TXLFN EURZQ IRA

    WKH TXLFN EURZQ IRA

    Move the slider. Each dot marks a shift you have tried.

    Frequency Analysis

    Frequency analysis finds the shift by matching the most common ciphertext letter to the most common English letter. The Arab scholar Al-Kindi described the method in the 9th century.

    Most common English letters

    E12.7%
    T9.1%
    A8.2%
    O7.5%
    I7.0%
    N6.7%

    Find the shift in 3 steps

    1. Count each letter in the ciphertext.
    2. Take the most common one, for example H.
    3. Count its distance to E: H (7) − E (4) = shift 3.

    Automated solvers score each shift against the full English letter table with the chi-squared statistic. The lowest score wins. This decoder adds points for common words such as "the" and "and".

    Line up the letter frequencies

    Chi-squared: –

    The message is a pangram encoded with an unknown shift. Slide until the message bars match the English bars. The lowest chi-squared score marks the right shift.

    Known-Plaintext Attack

    A known-plaintext attack finds the shift from 1 letter you already know. Short words like THE, AND, OF and TO make the best guesses, called cribs.

    1. Guess a crib. A ciphertext that starts with WKH often hides THE.
    2. Subtract the plain letter from the coded letter: W (22) − T (19) = 3.
    3. Test shift 3 on the rest of the message.

    Find a shift from 1 letter

    (22 − 19) mod 26 =3

    Why Short Messages Are Hard to Decode

    A few letters don't carry enough frequency data. A 5-letter word can turn into a real English word at 2 or 3 different shifts. The top result is usually right once a message has about 25 letters.

    4 tips for short messages

    • Check the top 3 results in the shift list, not only the first.
    • Try ROT13 first in CTF challenges.
    • Look for names, places and numbers that fit your context.
    • Try a Vigenère solver if no shift gives readable text.

    ROT13: The Caesar Cipher with a Shift of 13

    ROT13 is a Caesar cipher with a fixed shift of 13. The English alphabet has 26 letters, so 2 shifts of 13 bring each letter back to the start. The same step encodes and decodes:

    HELLOURYYB

    Usenet forums used ROT13 in the early 1980s to hide spoilers, puzzle answers and jokes. Press the ROT13 button in the tool to set the shift to 13.

    Hide and reveal a spoiler

    Gur ohgyre qvq vg.

    This line is a spoiler hidden with ROT13. Press the button to read it.

    ROT13 has 3 related variants:

    ROT1313 shiftLetters A to Z
    ROT55 shiftDigits 0 to 9
    ROT1813 + 5 shiftLetters and digits
    ROT4747 shift94 printable ASCII characters

    Numbers, Punctuation and Non-English Letters

    The alphabet decides which characters shift. Characters outside it stay unchanged.

    Uppercase and Lowercase Letters

    Each case shifts within its own alphabet. "Hello" with shift 3 becomes "Khoor". Set Letter case to ABC or abc to convert the output.

    Spaces, Numbers and Punctuation

    These pass through with the A to Z alphabet. Pick A to Z + 0 to 9 to shift digits: Z moves on to 0. Pick Remove for letters only, like WKHTXLFNEURZQIRA.

    Accented and Non-English Letters

    Letters such as é, ü, ñ and Ą stay unchanged by default. Choose Custom and type the full alphabet in order to shift them.

    AlphabetLettersHow to shift it
    Basic (A-Z)26Default setting
    A to Z plus 0 to 936Alphabet menu
    Spanish27 (adds Ñ)Custom alphabet
    German30 (adds Ä, Ö, Ü, ß)Custom alphabet
    Polish32 (adds Ą, Ć, Ę, Ł, Ń, Ó, Ś, Ź, Ż; drops Q, V, X)Custom alphabet
    French26 plus accents such as é and çCustom alphabet, or replace accents first

    Auto-detect scores results against English. For other languages, check the ranked list by eye.

    History of the Caesar Cipher

    The Caesar cipher dates to the 1st century BC. Roman historian Suetonius recorded the method in The Lives of the Twelve Caesars around AD 121.

    1. 1st century BCJulius Caesar shifts letters by 3
    2. AD 121Suetonius records the method
    3. 9th centuryAl-Kindi describes frequency analysis
    4. 16th centuryThe Vigenère cipher uses many shifts
    5. 1915The Russian army uses a Caesar cipher
    6. Early 1980sUsenet adopts ROT13 for spoilers
    7. 2006Provenzano's number cipher is broken

    Why Is It Called the Caesar Cipher?

    Julius Caesar replaced each letter with the letter 3 places later. Suetonius wrote that Caesar put D in place of A whenever a letter held something confidential.

    Augustus and Later Variants

    Augustus, Caesar's heir, used a shift of 1 and wrote AA for X without wrapping. Sicilian Mafia boss Bernardo Provenzano used a number-based variant until his arrest in 2006.

    Is the Caesar Cipher Secure?

    No, the Caesar cipher is not secure. It fails for 3 reasons:

    1Tiny key spaceOnly 25 useful keys exist. Brute force reads the message in seconds.
    2Fixed letter frequencyEvery E becomes the same coded letter, so frequency analysis finds the shift.
    3No integrity checkAnyone can change the coded text without being caught.

    The Caesar cipher has the smallest key space of any common cipher:

    Caesar cipher25 keys, under 1 ms
    Vigenère, 5-letter key11,881,376 keys, seconds
    AES-1282¹²⁸ ≈ 3.4 × 10³⁸ keys, longer than the age of the universe

    Bar length uses a log scale.

    The index of coincidence of English text stays at about 0.066 after any Caesar shift. Code breakers use that number to tell a single-shift cipher from a Vigenère cipher. Use the Caesar cipher for teaching and puzzles. Protect passwords and private data with the Advanced Encryption Standard (AES).

    Caesar Cipher Uses

    The Caesar cipher has 5 common uses today:

    TeachingPlaintext, ciphertext, keys and modular arithmetic in maths and computer science classes.
    CTF challengesHiding flags in beginner capture the flag (CTF) puzzles.
    Games and huntsClues for escape rooms, geocaches and treasure hunts.
    SpoilersHiding answers and plot twists with ROT13.
    Coding practiceA classic first exercise in Python, JavaScript, Java, C and PHP.

    Caesar Cipher Decoder in Python and Pseudocode

    A Caesar cipher decoder takes 12 lines of Python. The function shifts letters, keeps the case and leaves other characters alone:

    def caesar(text, shift, decode=False):
        if decode:
            shift = -shift
        result = []
        for ch in text:
            if ch.isupper():
                result.append(chr((ord(ch) - 65 + shift) % 26 + 65))
            elif ch.islower():
                result.append(chr((ord(ch) - 97 + shift) % 26 + 97))
            else:
                result.append(ch)
        return "".join(result)
    
    print(caesar("HELLO WORLD", 3))        # KHOOR ZRUOG
    print(caesar("KHOOR ZRUOG", 3, True))  # HELLO WORLD

    The Caesar cipher algorithm in pseudocode:

    FOR each character c in text
        IF c is a letter
            x = position of c (A = 0)
            y = (x + shift) mod 26     // use x - shift to decode
            output the letter at position y, in the case of c
        ELSE
            output c
        END FOR

    In JavaScript, Java and C, the % operator returns a negative number for negative input. Wrap the result to keep decoding correct:

    const mod = (n) => ((n % 26) + 26) % 26;
    const decodeLetter = (x, shift) => mod(x - shift);

    The Caesar cipher is the starting point for 7 related classical ciphers:

    Frequently Asked Questions

    Is the Caesar cipher always a shift of 3?

    ▼

    No, the Caesar cipher works with any shift from 1 to 25. A shift of 3 is the classic example, since Suetonius recorded that Julius Caesar used 3. Augustus used a shift of 1.

    How do you write "I love you" in Caesar cipher?

    ▼

    "I love you" with a shift of 3 is "L oryh brx". Each letter moves 3 places forward: I to L, L to O, O to R, V to Y, E to H, Y to B and U to X. A different shift gives a different result.

    What is the difference between the Caesar cipher and ROT13?

    ▼

    ROT13 is one Caesar cipher with a fixed shift of 13, and the Caesar cipher covers all 25 shifts. ROT13 decodes itself: applying ROT13 twice returns the original text.

    Is the Caesar cipher symmetric or asymmetric?

    ▼

    The Caesar cipher is symmetric. The same key, the shift value, encrypts and decrypts the message. Decryption moves letters back by the shift that encryption moved them forward.

    What are other names for the Caesar cipher?

    ▼

    The Caesar cipher has 5 other names: Caesar shift, Caesar code, shift cipher, additive cipher and rotation (ROT) cipher. "Additive cipher" comes from the formula, which adds the key to each letter's position.

    When was the Caesar cipher invented?

    ▼

    The Caesar cipher was in use by the 1st century BC, when Julius Caesar wrote with it during his campaigns. Older shift systems may exist, but Caesar's letters are the earliest recorded use.

    How long does a message need to be for auto-detect to work?

    ▼

    Auto-detect works best on messages of 25 letters or more. Messages under 10 letters often fit several shifts, so the top result can be wrong. Check the top 3 rows in the shift list for short text.

    Is my text sent to your server?

    ▼

    No, your text is not sent to our server. The decoder runs in your browser. Share links keep the message in the part of the address after the #, which browsers don't send to a server.

    Why does my decoded text still look wrong?

    ▼

    Your decoded text looks wrong when the mode, shift or alphabet differs from the one used to encode. Check that Decode is selected, the shift matches, and the alphabet includes every coded character. Try a Vigenère solver, if no shift gives readable text.

    How do you encrypt numbers with a Caesar cipher?

    ▼

    Encrypt numbers by choosing the A to Z plus 0 to 9 alphabet, which shifts digits along with letters. ROT5 is a second option. ROT5 shifts digits only, by 5 places: 0 becomes 5 and 7 becomes 2.