# Caesar Cipher Encoder/Decoder

URL: https://hifreetools.com/text/caesar-cipher

> Encode and decode messages with the classic Caesar shift cipher right in your browser. Choose any shift from 0 to 25, flip on the ROT13 preset, and the result updates live with case preserved and punctuation untouched.

## Quick answer

A Caesar cipher shifts every letter a fixed number of places down the alphabet. To encode, move each letter forward by the shift (so with shift 3, A becomes D); to decode, move each letter back by the same amount. This tool does both: type your text, set a shift of 0-25 (or click ROT13 for shift 13), and it transforms the text instantly while leaving spaces, digits, and punctuation unchanged.

Each letter is converted to its position in the alphabet (A=0 ... Z=25). For encoding, the tool adds the chosen shift and wraps around using modulo 26, so Z + 1 returns to A. For decoding it subtracts the shift instead. Uppercase and lowercase letters are shifted within their own range so case is preserved, and any character that is not an A-Z letter (spaces, numbers, punctuation, symbols) is copied through unchanged. ROT13 is simply a Caesar cipher with a shift of 13; because 13 is half of 26, applying it twice returns the original text, which is why the same operation both scrambles and unscrambles.

## Examples

- Encode "ABC" with shift 3: Text: ABC, Mode: Encode, Shift: 3 → DEF
- Decode "KHOOR" with shift 3: Text: KHOOR, Mode: Decode, Shift: 3 → HELLO
- ROT13 of "Hello": Text: Hello, Mode: Encode, Shift: 13 (ROT13) → Uryyb
- Encode a full sentence with shift 5: Text: Attack at dawn!, Mode: Encode, Shift: 5 → Fyyfhp fy ifbs!
- Wrap-around with shift 1: Text: Zebra, Mode: Encode, Shift: 1 → Afcsb

## FAQ

**What is a Caesar cipher?**
It is one of the oldest known encryption methods, named after Julius Caesar, who used it to protect military messages. Each letter in the text is replaced by a letter a fixed number of positions later in the alphabet. The fixed number is the key, also called the shift.

**How do I decode a Caesar cipher if I do not know the shift?**
Because there are only 25 possible shifts, you can brute-force it: try each shift from 1 to 25 and see which one produces readable text. Set this tool to Decode and step the shift through every value, or watch the alphabet-mapping preview until the output makes sense.

**What is ROT13 and how is it related?**
ROT13 is a Caesar cipher with a shift of exactly 13. Since the alphabet has 26 letters, shifting by 13 twice brings every letter back to where it started, so the same operation both encodes and decodes. Click the ROT13 preset to set shift 13 instantly.

**Does the tool keep uppercase, lowercase, and punctuation?**
Yes. Uppercase letters stay uppercase and lowercase stay lowercase because each is shifted within its own range. Spaces, numbers, and punctuation are not letters, so they are passed through unchanged.

**Is the Caesar cipher secure?**
No. With only 25 keys it can be broken instantly by trying every shift, and longer texts can be cracked by frequency analysis. Use it for puzzles, education, and casual obfuscation, never for passwords or confidential information.

**Is my text sent to a server?**
No. The entire encoding and decoding runs locally in your browser using JavaScript. Your text never leaves your device, so it is safe to use offline and with private content for puzzle purposes.

**What shift did Julius Caesar actually use?**
According to the Roman historian Suetonius, Caesar shifted letters by three places, which is why a shift of 3 is often called the classic Caesar cipher. You can reproduce it with the "Classic (3)" preset.


## Sources

- [Wikipedia - Caesar cipher](https://en.wikipedia.org/wiki/Caesar_cipher)
- [Wikipedia - ROT13](https://en.wikipedia.org/wiki/ROT13)

Runs in the browser; nothing is uploaded. Cite as: HIFreeTools, "Caesar Cipher Encoder/Decoder", https://hifreetools.com/text/caesar-cipher
