Skip to content
ToolBoxGeniehome

Caesar Cipher Encoder

Text Tools · Added

Named for Julius Caesar, who used it for military correspondence, the shift cipher moves every letter a fixed distance through the alphabet. Encode with any shift, decode with the same one, or — when you do not know the key, which is the usual situation with a puzzle — display all twenty-five possibilities at once and let letter frequency point at the one that reads like English.

What do you want to do?

Letters are shifted; digits, spaces and punctuation pass through untouched.

3

A shift of 13 is ROT13, which is its own inverse — encoding and decoding are the same operation. A shift of 0 leaves the text exactly as it is.

How to use the caesar cipher encoder

  1. 1Choose whether you want to encode, decode, or try every shift.
  2. 2Paste your text into the box. Digits, spaces and punctuation pass through untouched; only letters move.
  3. 3For encoding and decoding, drag the shift slider or use a preset. Thirteen is ROT13.
  4. 4The result appears as you type — there is nothing to submit.
  5. 5In the try-every-shift mode, read the highlighted row first: it is the shift whose output most closely matches English letter frequencies. Then check the table, because on a short message that ranking is a hint rather than an answer.

Examples

A shift of three, as Caesar used it

Input
ATTACK AT DAWN with a shift of 3
Result
DWWDFN DW GDZQ

A becomes D, T becomes W. Word lengths and spacing survive intact, which is a large part of why the cipher is so easy to break.

ROT13, which undoes itself

Input
Spoiler: the butler did it, at shift 13
Result
Fcbvyre: gur ohgyre qvq vg

Apply ROT13 to that output and the original comes back. Thirteen is half of twenty-six, so encoding and decoding are the same operation — which is why forums adopted it for spoilers.

Cracking one without the key

Input
Wkh txlfn eurzq ira mxpsv ryhu wkh odcb grj, in try-every-shift mode
Result
Shift 3 ranks first: The quick brown fox jumps over the lazy dog

Twenty-five candidates, scored against English letter frequencies. On a full sentence the winner is usually unambiguous.

About the caesar cipher encoder

How the shift works

Line up the alphabet, then line up a second copy underneath it moved along by a fixed number of places. That is the whole cipher. With a shift of three, A sits above D, B above E, and Z wraps round to C. Encoding reads down; decoding reads up, which is the same as shifting by twenty-six minus the key.

Because the mapping is fixed for the whole message, every occurrence of a given letter becomes the same other letter. That property is the cipher's fatal weakness and also what makes it easy to teach: the substitution is visible, reversible and requires nothing but counting. It is usually the first cipher anyone meets, and it introduces ideas — key, keyspace, ciphertext, brute force — that carry all the way to modern cryptography.

The keyspace is twenty-five, not twenty-six, because a shift of zero leaves the text unchanged. That is small enough to enumerate by hand, and small enough that this page can show every possibility at once rather than asking you to guess.

Frequency analysis, and where it stops working

Even without trying all twenty-five keys, a Caesar cipher falls to counting. In ordinary English text E is by far the most common letter, followed by T, A and O; Q, X, J and Z between them account for well under one per cent. A shift moves that whole distribution along by a fixed amount without changing its shape, so finding the offset that lines the observed counts back up with the expected ones recovers the key directly.

That is what the ranking on this page does, scored with a chi-squared statistic so that a rare letter turning up frequently — the strongest evidence that a shift is wrong — counts for much more than a small wobble in a common one. On a paragraph it is essentially always right. On a four-word phrase it is a suggestion, because a handful of letters cannot establish a distribution.

This is also why the same technique, extended, breaks the more elaborate substitution ciphers that replace each letter with an arbitrary other one. The shape of the language survives the substitution. Defeating it needs a cipher where the same plaintext letter does not always produce the same ciphertext letter — the insight behind the Vigenère cipher and, in a far stronger form, behind everything that followed.

Frequently asked questions

Is a Caesar cipher secure?
Not remotely, and it has not been for over a thousand years. There are only twenty-five possible keys, so trying all of them takes a computer no measurable time and a person about a minute — the try-every-shift mode on this page is that entire attack, implemented in a few lines. Arab scholars described frequency analysis, which breaks it even faster, in the ninth century. Use it for puzzles, crosswords and spoiler tags; use real cryptography for anything that matters.
What is ROT13 and why is it so common?
It is a Caesar cipher with a shift of thirteen. Because thirteen is exactly half of twenty-six, applying it twice returns the original text, so one operation serves for both encoding and decoding. That symmetry made it the convention on Usenet and later on forums for hiding punchlines, spoilers and answers — not to protect them, but to stop them being read accidentally.
How does the automatic guess work?
English letters appear with well-known frequencies — E at about 12.7%, T at 9.1%, Z at 0.07%. Each candidate decoding is scored by chi-squared distance between its letter distribution and those figures, and the lowest score wins. A wrong shift usually puts rare letters where common ones belong, which the test punishes heavily. It needs material to work with: below roughly thirty letters the distribution is too noisy to be reliable, and the page says so rather than presenting a coin toss as a result.
Why did the guess pick the wrong line?
Most likely because the text is not ordinary English. Another language, a string of names, deliberate wordplay, or a message that is itself in code will all score badly while still being the intended answer. That is exactly why the full table is shown rather than only the winner — the ranking is a shortcut through twenty-five options, not a verdict on them.
What happens to numbers, accents and punctuation?
They are left exactly as they are. The classical cipher is defined over the twenty-six unaccented letters, and shifting anything else would be an invention. It is also more useful this way: keeping the punctuation and word breaks preserves the shape of the message, which is what makes a decoded line recognisable at a glance.