Home › Ciphers › Caesar Cipher

Caesar Cipher

Shift every letter of a message the same distance through the alphabet and you have the oldest famous cipher in the world — the one Julius Caesar used, the one every codebreaker learns first, and the one that still turns up as the opening layer of puzzles today. This page encodes and decodes with any shift, live, and then teaches the cipher properly: where it came from, why it falls, and how to work it by hand.

In short

The Caesar cipher is a monoalphabetic shift cipher: every letter is replaced by the letter a fixed number of places later in the alphabet, wrapping from Z back to A. Caesar's own shift, reported by Suetonius, was three (A→D). With only 25 possible keys it offers no real security — it is a teaching cipher and a puzzle step.

Also called the shift cipher or Caesar shift. Shift 13 is ROT13. If you have a shifted message but do not know the shift, use the Caesar cipher solver, which tries all 25.

Encode or decode, with any shift

10 letters
Encoded · shift 3
KHOOR ZRUOG
Don't know the shift? Brute-force it →

Everything runs in your browser — nothing is uploaded.

How it works

One number is the whole key

Number the alphabet A=0 to Z=25, choose a shift s, and replace each letter at position x with the letter at position (x + s) mod 26. The mod 26 is the wrap-around: X shifted by 3 lands past Z, so it counts back to A. Decoding subtracts instead of adding — (x − s) mod 26 — which is why the same tool above works in both directions, and why a shift of 26 is no shift at all. There are exactly 25 shifts that change anything, and that small number is simultaneously the cipher's fatal weakness and its teaching gift: the entire key space fits on one screen.

What does not move

Only the 26 letters are shifted. Spaces stay spaces, so word lengths survive encryption untouched; numbers, punctuation and capitalisation pass through exactly as written, and a capital letter encodes to a capital letter. That fidelity is not a courtesy — it is the cipher's definition, and it is also its biggest leak. A message like PHHW PH DW WKH SDUN keeps the shape of MEET ME AT THE PARK: the two-letter word, the repeated three-letter word, the double letter waiting inside a longer one. Everything a solver needs is preserved by the very rule that makes the cipher easy to use.

Keyed and numeric variants

Two common variations stretch the basic idea without changing its nature. A keyed Caesar first scrambles the alphabet with a keyword (the way the substitution page builds one) and then applies a shift — the result is still a fixed substitution, just harder to guess from the shift alone. A numeric Caesar works on digits instead of letters, rotating 0–9 by a fixed amount; ROT5, the digit member of the ROT family, is its famous half-turn form. Neither variant survives the attacks in the Breaking section — a keyed alphabet falls to the cryptogram solver, and ten digits brute-force even faster than 26 letters.

The wheel: the formula as an object

Slide the shift control above and watch the alphabet strip re-align: that strip is the cipher. Print it as two concentric discs — the Caesar wheel — and you can rotate the inner disc to any of the 25 alignments and read encodings off by eye. The wheel is not a toy version of the tool; it is the same lookup, made physical, and for two thousand years it was the fastest hardware available.

Origin & history

Suetonius, Augustus, and the first frequency analyst

The cipher carries Caesar's name because the Roman historian Suetonius, writing around AD 121 in his Lives of the Twelve Caesars, describes him using it for correspondence he wanted kept from casual readers: each letter shifted three places, A written as D. It was privacy against the unmotivated — a courier or a rival glancing at the tablet saw nonsense — and for that purpose it worked. Suetonius also records the emperor Augustus using a shift of one, with a telling sloppiness: reaching the end of the alphabet, he wrote a doubled A instead of wrapping around to the start. Even emperors found the wrap-around the fiddly part.

The method that eventually killed every shift and substitution cipher was described in the ninth century by the Arab philosopher and mathematician al-Kindi, whose treatise on deciphering cryptographic messages contains the earliest surviving account of frequency analysis: letters occur at predictably different rates in any language, so counting the symbols in a ciphertext betrays what they stand for. Against Caesar specifically you rarely need al-Kindi's full method — trying all 25 shifts is quicker — but the ranking that makes brute force automatic is his insight in modern dress: the correct shift is the one whose letter counts look like the language.

  • c. 100 BC — Caesar uses a shift of three (reported by Suetonius, c. AD 121).
  • c. AD 1 — Augustus uses a shift of one, without proper wrap-around.
  • 9th century — al-Kindi describes frequency analysis, the attack that still works.
  • 1900 — Pearson's chi-squared test turns “looks like English” into a score.
  • 1980s — ROT13, the shift of thirteen, becomes the internet's spoiler curtain.
Reference

The alphabet, shifted by three

The classical alignment — the one Suetonius reports — reads like this. Encoding reads down from the top row; decoding finds the cipher letter in the bottom row and reads up.

PlainA B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Cipher (shift 3)D E F G H I J K L M N O P Q R S T U V W X Y Z A B C

Every other shift is the same picture slid sideways: at shift 5 the bottom row simply starts at F. Puzzle culture often hides the shift inside a two-letter code naming one letter's mapping — the distance between the two letters is the key:

Code nameThe clue meansShift
CD codeC becomes D1
Hello (LO) codeL becomes O3
Eiffel (FL) codeF becomes L6
Empty (MT) codeM becomes T7
See You (CU) codeC becomes U18
Easy (EZ) codeE becomes Z21

Meet one of these in a hunt and you can either set the shift by hand above, or paste the text into the solver and let it try every disguise in the table — and the nineteen others besides.

Worked examples

Three encodings, generated by the tool above

Example 1 — the classic: HELLO WORLD at shift 3

HELLO WORLD → KHOOR ZRUOG

Letter by letter: H→K, E→H, L→O, O→R, W→Z, R→U, D→G. Each letter moves three places forward, and the shape of the message is unchanged — word lengths and the repeated letter (the double L becomes a double O) survive encryption exactly. That survival is the clue every attack exploits.

Example 2 — a full message at shift 7

AOL OPZAVYF VM ZLJYLA DYPAPUN PZ SVUN HUK MBSS VM ZBYWYPZLZ. NLULYHSZ, RPUNZ HUK SVCLYZ OHCL HSS AYBZALK ZPTWSL TLAOVKZ AV OPKL AOLPY TLZZHNLZ MYVT JBYPVBZ LFLZ…

The plaintext is the opening of this site's test sentence — “THE HISTORY OF SECRET WRITING IS LONG AND FULL OF SURPRISES. GENERALS, KINGS AND LOVERS HAVE ALL TRUSTED SIMPLE METHODS TO HIDE THEIR MESSAGES FROM CURIOUS EYES…” At over 200 letters, the evidence is overwhelming: run this through the solver and shift 7 does not merely win, it wins by a margin that leaves no room for doubt.

Example 3 — decoding at shift 11

ESP ECPLDFCP TD MFCTPO FYOPC ESP ZWO ZLV ECPP

Set the tool to Decode with shift 11 — or count the commonest pattern: ESP appears three times where a three-letter word belongs, and at shift 11 ESP is THE. The message reads “THE TREASURE IS BURIED UNDER THE OLD OAK TREE”. Finding the shift from the repeated word is the by-hand version of what the solver automates.

Breaking it

Twenty-five keys is not a key space, it is a checklist

Caesar falls to the simplest attack in cryptanalysis: brute force. Decode the message 25 times and read the one that is English. The solver on this site does exactly that and ranks the attempts with two scores — a chi-squared comparison of each attempt's letter counts against published English frequencies, and a check of how many of its words are real words. On a sentence or more the correct shift wins by a wide margin; the ranking, not just the answer, is what tells you to trust it.

By hand, the classic route is al-Kindi's: count the letters. In English text E dominates (about 12.7% of letters), so the commonest ciphertext letter is probably E in disguise, and the distance from it to E is the shift. One-letter words narrow it further — a lone shifted letter must be A or I — and a repeated three-letter word is very often THE. The honest limits are about length, not method: under a sentence, frequency evidence thins out, and a five-letter ciphertext can have two pronounceable decodings. On short text the solver shows all 25 rows precisely so a human can overrule the scorer.

  • Security status: none. A Caesar cipher defeats only readers who do not try.
  • What gives it away: English-shaped letter frequencies, shifted; word lengths and repeated-letter patterns intact.
  • If no shift reads as English: it is not Caesar. English-shaped frequencies with no winning shift mean a scrambled substitution; flat frequencies suggest Vigenère. The Identifier separates the three in one paste.
Variants

ROT13, Atbash, and the road to Vigenère

RelativeHow it differsSolve it with
ROT13Caesar frozen at shift 13; because 13 is half of 26, encoding and decoding are the same operationThe ROT13 page, or this tool at shift 13
ROT-N“ROT” plus any number is Caesar by another name — ROT5 twists digits, ROT47 twists printable ASCIIThis tool for letters; the ROT page for the rest
AtbashNot a shift but a mirror: A↔Z, B↔Y. No shift will ever decode itThe Atbash page — or spot GSV standing for THE
VigenèreA Caesar whose shift changes letter by letter under a keyword — the fix history applied to Caesar's weaknessThe Vigenère page to encode; its solver to attack

The distinction that matters most is Caesar versus general substitution: Caesar is the special case where the scrambled alphabet happens to be a rotation. Everything that breaks substitution breaks Caesar faster, because Caesar's attacker can also just enumerate the rotations.

Uses & culture

Where shifted text still lives

Caesar's modern career is educational and playful, and it is enormous. It is the first cipher in nearly every cryptography course and children's code book, usually delivered on a cardboard decoder wheel — the direct descendant of the alignment strip above. Puzzle hunts and escape rooms use a shift as the warm-up layer before the real cipher; CTF competitions traditionally make a Caesar message the first flag, because recognising it instantly is the entry ticket. Geocaching hides hints and coordinates behind small shifts, and the two-letter code names in the reference table exist because hunt designers needed a way to hint a shift without printing it. And ROT13's separate afterlife — the spoiler curtain of Usenet, still honoured by geocaching.com hints and programmer in-jokes — is Caesar wearing its most famous fixed shift. A cipher everyone can break, that everyone agrees to break only on purpose, turned out to be a durable social tool.

Practice

Two shifts to crack by eye

Guess the shift from the shortest common word first, then check yourself with the solver's ranking.

Practice 1

PHHW PH DW WKH SDUN DW PLGQLJKW DQG EULQJ WKH NHB
Reveal the answer

Shift 3. DW is a two-letter word that must be AT, AS or TO — and WKH right after it is THE at the same shift. “MEET ME AT THE PARK AT MIDNIGHT AND BRING THE KEY.”

Practice 2

ESP ECPLDFCP TD MFCTPO FYOPC ESP ZWO ZLV ECPP
Reveal the answer

Shift 11 — the same ciphertext as Worked Example 3. ESP appears three times, and at this shift it is THE; the message is “THE TREASURE IS BURIED UNDER THE OLD OAK TREE”. Notice that the most common single letter, P, is E shifted by 11 — al-Kindi's method would have found this shift from the counts alone.

The printable wheel in the sidebar is the by-hand version of this page: two alphabet discs, one pin, all 25 shifts in your pocket.

FAQ

Frequently asked questions

How do I decode a Caesar cipher if I don't know the shift?

Use the Caesar cipher solver: it decrypts with all 25 shifts and ranks them by English-likeness, so the right one is normally at the top. By hand, look at the most common ciphertext letter — it is probably E shifted — and set the shift from the distance between the two.

Can two different shifts both produce readable text?

On a word or two, occasionally — very short strings are under-determined, and a five-letter ciphertext can have more than one pronounceable decryption. It is a length problem, not a solver problem: on a full sentence the true shift wins by a wide statistical margin. If you only have a few letters, let context decide — the reading that fits the puzzle's theme beats one that is merely pronounceable.

What is the difference between Caesar and ROT13?

ROT13 is Caesar with the shift fixed at 13 — nothing more. The special property of 13 is that it is half the alphabet, so applying ROT13 twice returns the original text: encode and decode are the same operation. Caesar with any other shift needs the opposite movement to undo it.

Why does the tool keep my punctuation, numbers and capitalisation?

Because the cipher does. Caesar shifting is defined on letters only; a faithful tool mirrors the cipher exactly, preserving word lengths, spacing and every non-letter — all of which are evidence a solver may need for the next step.

Is a Caesar cipher with a really big shift any safer?

No — there is no big shift. Shifts repeat every 26, so shift 29 is shift 3 and shift 1,000 is shift 12. The key space is 25 no matter how large a number is written down, and brute force covers all of it instantly.

Does my text leave my device?

No. The encoding, decoding and alphabet strip all run in your browser.

Next steps