ToolNimba Browse

🔐 Caesar Cipher Encoder and Decoder

By ToolNimba Editorial Team · Updated 2026-06-19

Enter some text to see the cipher result.

A Caesar cipher shifts every letter in your message a fixed number of places along the alphabet, so A with a shift of 3 becomes D and Z wraps back round to C. Type or paste your text, choose a shift from 1 to 25, and pick encode or decode. The result updates instantly, case is preserved, and spaces, numbers and punctuation are left exactly as they are.

What is the Caesar Cipher?

The Caesar cipher is one of the oldest and simplest encryption methods, named after Julius Caesar, who reportedly used a shift of 3 to protect military messages. It is a substitution cipher: each letter of the plaintext is replaced by the letter a fixed number of positions further down the alphabet. With a shift of 3, A maps to D, B maps to E, and so on, with X, Y and Z wrapping around to A, B and C. Only the 26 letters are touched, so digits, spaces and punctuation pass through unchanged, and the case of each letter is preserved.

Decoding is just encoding in reverse. If a message was encoded with a shift of 3, you decode it by shifting every letter back by 3, which is the same as shifting forward by 26 minus 3, that is 23. Because the alphabet is a closed loop of 26 letters, shifting forward by 23 lands you in exactly the same place as shifting back by 3. That is why a Caesar tool can decode simply by applying the complementary shift, and why a shift of 13 (ROT13) is its own inverse: shifting twice by 13 returns you to the start.

The Caesar cipher is fun and useful for puzzles, learning and lightly obscuring text such as spoilers, but it offers no real security. There are only 25 usable shifts, so an attacker can simply try them all in seconds, a method called brute force. It can also be broken by frequency analysis, since the most common letter in the ciphertext usually corresponds to a common letter like E in English. For anything that genuinely needs protecting, use modern encryption rather than a shift cipher.

When to use it

  • Solving or creating Caesar cipher puzzles in escape rooms, treasure hunts and classroom exercises.
  • Teaching the basics of cryptography, substitution and modular arithmetic in an interactive way.
  • Lightly hiding spoilers, answers or surprises so they are not readable at a glance.
  • Decoding a message when you know (or want to guess) the shift that was used.

How to use the Caesar Cipher

  1. Type or paste the text you want to transform into the input box.
  2. Choose a shift from 1 to 25 (3 is the classic Caesar shift, 13 is ROT13).
  3. Pick Encode to shift letters forward, or Decode to shift them back.
  4. Read the result below and use the Copy button to grab it.

Formula & method

For each letter: encoded = (position + shift) mod 26, where position is 0 for A up to 25 for Z. To decode, use (position + 26 - shift) mod 26. Non-letters are left unchanged and case is preserved.

Worked examples

Encode the word HELLO with a shift of 3 (the classic Caesar cipher).

  1. H is position 7, so 7 + 3 = 10, which is K
  2. E is position 4, so 4 + 3 = 7, which is H
  3. L is position 11, so 11 + 3 = 14, which is O
  4. L again gives O
  5. O is position 14, so 14 + 3 = 17, which is R

Result: HELLO becomes KHOOR

Decode KHOOR, knowing it was encoded with a shift of 3.

  1. Decoding shifts back by 3, the same as shifting forward by 26 - 3 = 23
  2. K is position 10, so 10 + 23 = 33, and 33 mod 26 = 7, which is H
  3. H gives 7 + 23 = 30, 30 mod 26 = 4, which is E
  4. O gives 14 + 23 = 37, 37 mod 26 = 11, which is L (twice)
  5. R gives 17 + 23 = 40, 40 mod 26 = 14, which is O

Result: KHOOR decodes back to HELLO

How A through E map under common shifts

Plain letterShift 1Shift 3 (Caesar)Shift 13 (ROT13)Shift 25
ABDNZ
BCEOA
CDFPB
DEGQC
EFHRD

Notable shift values and what they do

ShiftNameNote
3Caesar shiftThe shift Julius Caesar is said to have used.
13ROT13Its own inverse: encode and decode use the same shift.
1 to 25General CaesarAny of these 25 shifts gives a valid cipher.
0 or 26No shiftLeaves the text unchanged, so it is not used.

Common mistakes to avoid

  • Decoding with the wrong shift. To read a message you must use the same shift it was encoded with. If you do not know it, try each of the 25 shifts until the output reads as plain language, this is the brute-force approach.
  • Expecting it to be secure. A Caesar cipher has only 25 possible keys and is trivial to break by trying them all or by frequency analysis. Treat it as a puzzle or obfuscation, never as real encryption for sensitive data.
  • Thinking ROT13 needs a separate decode step. ROT13 is a shift of 13, and 13 + 13 = 26, a full loop. Applying ROT13 a second time returns the original text, so encode and decode are the same operation.
  • Forgetting that only letters shift. Numbers, spaces and punctuation are not part of the 26-letter alphabet, so they stay exactly as they are. If you expected a digit or symbol to change, that is why it did not.

Glossary

Plaintext
The original, readable message before it is encrypted.
Ciphertext
The scrambled output produced after the cipher is applied.
Shift (key)
The fixed number of positions each letter moves along the alphabet, from 1 to 25.
Substitution cipher
A cipher that replaces each letter with another according to a fixed rule, as the Caesar cipher does.
ROT13
A Caesar cipher with a shift of 13 that is its own inverse, so the same operation encodes and decodes.
Brute force
Trying every possible key in turn, which breaks a Caesar cipher in at most 25 attempts.

Frequently asked questions

What is a Caesar cipher?

A Caesar cipher is a substitution cipher that shifts every letter in a message a fixed number of places along the alphabet. With a shift of 3, A becomes D, B becomes E, and Z wraps around to C. It is named after Julius Caesar, who is said to have used a shift of 3 for his correspondence.

How do I decode a Caesar cipher?

Decode by shifting each letter back by the same number it was encoded with. In this tool, set the same shift and choose Decode. If you do not know the shift, try each of the 25 possibilities until the text reads as plain language.

Is ROT13 a Caesar cipher?

Yes. ROT13 is simply a Caesar cipher with a shift of 13. Because 13 is exactly half of 26, applying it twice returns the original text, so the same operation both encodes and decodes. Set the shift to 13 here to use it.

Is the Caesar cipher secure?

No. With only 25 usable shifts it can be broken almost instantly by trying every key, and the letter patterns can be cracked with frequency analysis. It is great for puzzles and learning, but never use it to protect sensitive information.

What happens to numbers and punctuation?

Only the 26 letters A to Z (in both cases) are shifted. Digits, spaces, punctuation and symbols pass through unchanged, and the case of each letter is preserved, so an uppercase letter stays uppercase.

What shift should I use?

Any shift from 1 to 25 works. A shift of 3 is the classic Caesar choice, and 13 gives you ROT13. A shift of 0 or 26 would leave the text unchanged, which is why those are not offered.