The Caesar cipher is the oldest and simplest substitution cipher. According to Suetonius, Julius Caesar wrote confidential letters by replacing each letter with the one three places further on in the alphabet, so A became D and “VENI” became “YHQL”. Shifting back by the same amount restores the message, and letters at the end wrap around to the start, which is exactly what the modulo operation in the formula does.
With only 25 useful shifts in the Latin alphabet, the cipher offers no real security: anyone can try them all in seconds, and frequency analysis finds the answer even faster because the most common letter in the ciphertext usually stands for E. The crack mode does both – it lists every possible shift and highlights the one whose letter frequencies best match English. Caesar shifts are still everywhere in puzzles, escape rooms and geocaches, and ROT13 (a shift of 13, which is its own inverse) is used online to hide spoilers and punchlines.
The same idea works in any alphabet; the tool uses 24 letters for Greek, 33 for Russian Cyrillic, 22 for Hebrew (final forms count as their base letters) and 28 for Arabic. Case, spaces, digits and punctuation are kept.
How to use the Caesar Cipher Encoder and Decoder
- Message
- Alphabet
- Shift (key) — Number of places each letter moves; negative values shift backwards.
- Mode
Everything is calculated in your browser, so results appear instantly and nothing you type is sent to a server.
How it works
Each letter’s position in the chosen alphabet is shifted by n modulo the alphabet length; non-letters are copied unchanged and the letter case is preserved. In crack mode the message is decoded with every shift and, for Latin text of at least 8 letters, a chi-squared comparison with English letter frequencies picks the most likely one.
Worked example
Encode “SKY” with shift 5: S (18) → 23 = X, K (10) → 15 = P, Y (24) → 29 mod 26 = 3 = D, giving XPD. Decoding “GTC” with shift 5 gives G − 5 = B, T − 5 = O, C − 5 = 23 = X: BOX. Caesar’s own “Veni, vidi, vici” with shift 3 becomes “Yhql, ylgl, ylfl”.
Famous shifts
| Shift | Name / use | A becomes |
|---|---|---|
| 1 | Augustus’s cipher (per Suetonius) | B |
| 3 | Julius Caesar | D |
| 13 | ROT13 – spoilers online | N |
| 25 | Same as shifting back by 1 | Z |
Formula
Encode: C = (P + n) mod m · Decode: P = (C − n) mod m
m = letters in the alphabet (26 for Latin); ROT13 = shift 13, its own inverse
Worked example
Inputs — Message: Veni, vidi, vici; Alphabet: Latin (A–Z, 26 letters); Shift (key): 3; Mode: Encode (shift forward).
Results — Result = Yhql, ylgl, ylfl; Most likely shift (English letter frequencies) = Shift 17 (decrypts to: Enwr, ermr, erlr); Effective shift = 3; Shift that reverses it = 23; Alphabet mapping = ABCDEFGHIJKLMNOPQRSTUVWXYZ
DEFGHIJKLMNOPQRSTUVWXYZABC; All possible shifts = Shift back by Decrypted (first line)
──────────────────────────────────────
1 Udmh, uhch, uhbh
2 Tclg, tgbg, tgag
3 Sbkf, sfaf, sfzf
4 Raje, reze, reye
5 Qzid, qdyd, qdxd
6 Pyhc, pcxc, pcwc
7 Oxgb, obwb, obvb
8 Nwfa, nava, naua
9 Mvez, mzuz, mztz
10 Ludy, lyty, lysy
11 Ktcx, kxsx, kxrx
12 Jsbw, jwrw, jwqw
13 Irav, ivqv, ivpv
14 Hqzu, hupu, huou
15 Gpyt, gtot, gtnt
16 Foxs, fsns, fsms
17 Enwr, ermr, erlr
18 Dmvq, dqlq, dqkq
19 Clup, cpkp, cpjp
20 Bkto, bojo, boio
21 Ajsn, anin, anhn
22 Zirm, zmhm, zmgm
23 Yhql, ylgl, ylfl
24 Xgpk, xkfk, xkek
25 Wfoj, wjej, wjdj.
Key terms
- Shift (key)
- The number of positions each letter moves.
- Plaintext / ciphertext
- The readable message and its encrypted form.
- Modulo
- The remainder after division, used to wrap around the alphabet.
- Frequency analysis
- Breaking a cipher by comparing letter frequencies with those of the language.
Frequently asked questions
How does the Caesar cipher work?
Every letter is replaced by the letter n places later in the alphabet, wrapping from Z back to A. With n = 3, A → D, X → A.
How do I decode a Caesar cipher without the key?
Try all 25 shifts (crack mode lists them) or use frequency analysis: the most common ciphertext letter often stands for E.
What is ROT13?
A Caesar shift of 13. Applying it twice gives back the original, so the same operation encodes and decodes.
What shift did Julius Caesar use?
Three, according to the Roman historian Suetonius.
Is a shift of 29 different from 3?
No – in a 26-letter alphabet shifts repeat every 26, so 29 ≡ 3.
Is the Caesar cipher secure?
Not at all; it has only 25 keys. Use it for puzzles and teaching, never for real secrets.
Can I encode numbers?
Digits are left unchanged; only letters of the chosen alphabet are shifted.