Skip to content

Caesar cipher encoder and decoder

How it works

The Caesar cipher replaces every letter with another letter a fixed distance away in the alphabet. With the default shift of 3, A becomes D, B becomes E, and X wraps around to A. The same shift is applied to every letter, so the rule never changes in the middle of a message.

Encoding moves forward by the selected shift. Decoding moves backward by that same amount. The alphabet is circular: moving beyond Z continues again at A. This tool converts letters to uppercase before processing. By default it removes spaces and punctuation so the result matches the compact form commonly used in cipher exercises.

Turn on Preserve spaces and punctuation when you want the layout to remain readable. Letters are still shifted, while spaces, numbers, line breaks, and punctuation stay in place. The original input field is never rewritten; the transformed text appears only in the Result field.

A shift is simply a number from 1 through 25. Shift 0 would leave the text unchanged, while shift 26 would repeat the alphabet and do the same thing, so neither is useful. If you do not know the shift used by a ciphertext, choose Brute force all shifts to see all 25 possible plaintext candidates at once.

Worked example

Encode HELLO with a shift of 3. Convert each letter to its alphabet position, add 3, and wrap around after Z when necessary.

Plain letterPositionShifted positionCipher letter
H88 + 3 = 11K
E55 + 3 = 8H
L1212 + 3 = 15O
L1212 + 3 = 15O
O1515 + 3 = 18R
  1. Enter the text: Type or paste HELLO into the Input text field.
  2. Choose the mode and shift: Select Encode and keep the shift set to 3.
  3. Move each letter: Advance every letter three alphabet positions, wrapping after Z.
  4. Read the result: The letters K, H, O, O, R combine to form KHOOR.

Reading the final column gives KHOOR. Decoding applies minus 3: K returns to H, H returns to E, and each O returns to L. A longer standard check is ATTACKATDAWNDWWDFNDWGDZQ with shift 3.

History and origin

The cipher is named for Julius Caesar. The Roman writer Suetonius described Caesar replacing letters in private correspondence so that a reader had to move through the alphabet to recover the message. The reported system corresponds to a fixed alphabet shift, although modern descriptions standardize the direction and number more neatly than ancient writing did.

Simple shifted alphabets appeared in many later puzzle, military, and educational settings because they are easy to perform by hand. The name “Caesar cipher” now covers every fixed rotation of the Latin alphabet, not only shift 3. ROT13 is a special member of the same family with its shift permanently set to 13.

How to break it

The Caesar cipher is not secure by modern standards. It has only 25 meaningful keys. An attacker can decode the same ciphertext with every possible shift and read the candidate that forms ordinary language. The brute-force button on this page demonstrates the entire attack in a fraction of a second.

Longer messages are also vulnerable to frequency analysis. In English, letters such as E, T, A, and O occur often. A shifted message preserves those frequency peaks; it only moves them to different letters. Comparing the most common ciphertext letters with expected English frequencies often reveals the shift without trying every key.

Use the Caesar cipher for education, puzzles, escape rooms, or lightweight obfuscation only. It does not protect passwords, personal messages, or confidential data. Anyone who recognizes the pattern can reverse it almost immediately.

Frequently asked questions

How do I decode a Caesar cipher without knowing the shift?

Try all 25 possible backward shifts and look for readable language. The Brute force all shifts button lists every candidate without changing your input.

What is the default shift in a Caesar cipher?

Shift 3 is the traditional default associated with Julius Caesar, but any whole number from 1 to 25 defines a valid Caesar shift.

Does a Caesar cipher preserve spaces and punctuation?

Classical worksheets often remove them. This tool strips them by default and offers a toggle that keeps spaces, numbers, line breaks, and punctuation in place.

Is the Caesar cipher secure?

No. Its key space contains only 25 useful shifts, and letter frequencies remain visible. It is suitable for puzzles and teaching, not for protecting private information.

What happens when a shifted letter passes Z?

The alphabet wraps around. With shift 3, X becomes A, Y becomes B, and Z becomes C.

Are ROT13 and the Caesar cipher the same?

ROT13 is one specific Caesar cipher. It always uses shift 13, while a general Caesar cipher lets you choose any shift from 1 to 25.

Privacy note

All processing happens in your browser. Your text never leaves your device and is never transmitted to ToolPlex.