Caesar Cipher and ROT13 Encoder and Decoder, with Brute-Force Shifts
Decoding “Wkh txlfn eurzq ira mxpsv ryhu wkh odcb grj.” with a Caesar shift of 3 gives “The quick brown fox jumps over the lazy dog.”. Pick a shift from 1 to 25 (ROT13 is shift 13, which encodes and decodes in one step), or switch to ROT47, Vigenère or Atbash; upper and lower case and every non-letter are kept, and digits can be shifted too. If you do not know the shift, the table below tries all 25 and marks the one whose letter frequencies are closest to English (chi-squared): here it is shift 3. These are classical puzzle ciphers, not secure encryption: anyone can undo them in seconds.
Updated Runs in your browser: nothing you enter is uploadedHow this tool works
Stays in your browser. Nothing you type is sent anywhere or saved.
A puzzle, not a lock. These classical ciphers can be undone by anyone in seconds. Do not use them to protect anything private; for that, make a strong secret with thePassword Generator and check data with hashes in theHash Generator.
Your text
Result
Decoded with a Caesar shift of 3: 35 letters converted, 9 other characters kept unchanged.
All 25 Caesar shifts
Your text is decoded with every shift from 1 to 25 (whatever method is chosen above). The row whose letter frequencies are closest to English, by a chi-squared score where lower is better, is highlighted.
Shift 3 looks most like English (χ² 109.3, lowest of the 25).
| Shift | Decoded text | χ² score |
|---|---|---|
| Shift 1 | Vjg swkem dtqyp hqz lworu qxgt vjg ncba fqi. | 626.7 |
| Shift 2 | Uif rvjdl cspxo gpy kvnqt pwfs uif mbaz eph. | 141.8 |
| Shift 3Most English-like | The quick brown fox jumps over the lazy dog. | 109.3 |
| Shift 4 | Sgd pthbj aqnvm enw itlor nudq sgd kzyx cnf. | 203.4 |
| Shift 5 | Rfc osgai zpmul dmv hsknq mtcp rfc jyxw bme. | 132.0 |
| Shift 6 | Qeb nrfzh yoltk clu grjmp lsbo qeb ixwv ald. | 214.4 |
| Shift 7 | Pda mqeyg xnksj bkt fqilo kran pda hwvu zkc. | 251.2 |
| Shift 8 | Ocz lpdxf wmjri ajs ephkn jqzm ocz gvut yjb. | 696.1 |
| Shift 9 | Nby kocwe vliqh zir dogjm ipyl nby futs xia. | 122.9 |
| Shift 10 | Max jnbvd ukhpg yhq cnfil hoxk max etsr whz. | 271.3 |
| Shift 11 | Lzw imauc tjgof xgp bmehk gnwj lzw dsrq vgy. | 303.4 |
| Shift 12 | Kyv hlztb sifne wfo aldgj fmvi kyv crqp ufx. | 156.3 |
| Shift 13 | Jxu gkysa rhemd ven zkcfi eluh jxu bqpo tew. | 232.3 |
| Shift 14 | Iwt fjxrz qgdlc udm yjbeh dktg iwt apon sdv. | 172.7 |
| Shift 15 | Hvs eiwqy pfckb tcl xiadg cjsf hvs zonm rcu. | 129.2 |
| Shift 16 | Gur dhvpx oebja sbk whzcf bire gur ynml qbt. | 136.9 |
| Shift 17 | Ftq cguow ndaiz raj vgybe ahqd ftq xmlk pas. | 351.8 |
| Shift 18 | Esp bftnv mczhy qzi ufxad zgpc esp wlkj ozr. | 694.9 |
| Shift 19 | Dro aesmu lbygx pyh tewzc yfob dro vkji nyq. | 129.5 |
| Shift 20 | Cqn zdrlt kaxfw oxg sdvyb xena cqn ujih mxp. | 480.4 |
| Shift 21 | Bpm ycqks jzwev nwf rcuxa wdmz bpm tihg lwo. | 251.7 |
| Shift 22 | Aol xbpjr iyvdu mve qbtwz vcly aol shgf kvn. | 156.7 |
| Shift 23 | Znk waoiq hxuct lud pasvy ubkx znk rgfe jum. | 315.4 |
| Shift 24 | Ymj vznhp gwtbs ktc ozrux tajw ymj qfed itl. | 376.4 |
| Shift 25 | Xli uymgo fvsar jsb nyqtw sziv xli pedc hsk. | 177.3 |
The ciphers compared on “Hello, World!”
| Cipher | Setting | Result | Keys | Same both ways |
|---|---|---|---|---|
| Caesar shift | Shift 3 | Khoor, Zruog! | 25 | No (decode shifts back) |
| Caesar shift | Shift 1 | Ifmmp, Xpsme! | 25 | No (decode shifts back) |
| ROT13 | Shift 13 | Uryyb, Jbeyq! | 1 | Yes |
| ROT47 | Shift 47 of 94 characters | w6==@[ (@C=5P | 1 | Yes |
| Atbash | A↔Z, B↔Y | Svool, Dliow! | 1 | Yes |
| Vigenère | Key LEMON | Sixzb, Hsdzq! | 26 to the power of the key length | No (decode subtracts the key) |
Alphabet under ROT13, Atbash and a shift of 3
| Plain | ROT13 | Atbash | Caesar +3 |
|---|---|---|---|
| A | N | Z | D |
| B | O | Y | E |
| C | P | X | F |
| D | Q | W | G |
| E | R | V | H |
| F | S | U | I |
| G | T | T | J |
| H | U | S | K |
| I | V | R | L |
| J | W | Q | M |
| K | X | P | N |
| L | Y | O | O |
| M | Z | N | P |
| N | A | M | Q |
| O | B | L | R |
| P | C | K | S |
| Q | D | J | T |
| R | E | I | U |
| S | F | H | V |
| T | G | G | W |
| U | H | F | X |
| V | I | E | Y |
| W | J | D | Z |
| X | K | C | A |
| Y | L | B | B |
| Z | M | A | C |
English letter frequencies used for the score
| Rank | Letter | Share of letters | Expected in 100 letters |
|---|---|---|---|
| 1 | E | 12.702% | 12.7 |
| 2 | T | 9.056% | 9.1 |
| 3 | A | 8.167% | 8.2 |
| 4 | O | 7.507% | 7.5 |
| 5 | I | 6.966% | 7.0 |
| 6 | N | 6.749% | 6.7 |
| 7 | S | 6.327% | 6.3 |
| 8 | H | 6.094% | 6.1 |
| 9 | R | 5.987% | 6.0 |
| 10 | D | 4.253% | 4.3 |
| 11 | L | 4.025% | 4.0 |
| 12 | C | 2.782% | 2.8 |
| 13 | U | 2.758% | 2.8 |
| 14 | M | 2.406% | 2.4 |
| 15 | W | 2.36% | 2.4 |
| 16 | F | 2.228% | 2.2 |
| 17 | G | 2.015% | 2.0 |
| 18 | Y | 1.974% | 2.0 |
| 19 | P | 1.929% | 1.9 |
| 20 | B | 1.492% | 1.5 |
| 21 | V | 0.978% | 1.0 |
| 22 | K | 0.772% | 0.8 |
| 23 | J | 0.153% | 0.2 |
| 24 | X | 0.15% | 0.2 |
| 25 | Q | 0.095% | 0.1 |
| 26 | Z | 0.074% | 0.1 |
How to encode or decode a Caesar cipher
- Paste your text. Type or paste it in the text box, for example “Wkh txlfn eurzq ira mxpsv ryhu wkh odcb grj.”. Case, spaces and punctuation are kept as they are.
- Choose Encode or Decode and a method. Pick Caesar shift and set a number from 1 to 25, or choose ROT13, ROT47, Vigenère (with a key word) or Atbash. Tick “Also shift digits” to rotate 0 to 9 as well.
- Read the result. The converted text appears as you type: with a shift of 3, decoding gives “The quick brown fox jumps over the lazy dog.”. Copy it with the Copy button.
- Do not know the shift? Read the brute-force table. Every shift from 1 to 25 is shown with its decoded text and a chi-squared score. The lowest score is the most English-like and is marked, here shift 3. Short texts can fool it, so check the readable line yourself.
Frequently asked questions
- What is ROT13?
- ROT13 is a Caesar cipher with a shift of 13. Because the alphabet has 26 letters, applying it twice gives back the original, so one setting encodes and decodes. “Hello, World!” becomes “Uryyb, Jbeyq!”. It is used to hide spoilers and punchlines, not to keep secrets.
- How do I decode a Caesar cipher if I do not know the shift?
- Try all 25 shifts and keep the one that reads as English. There are only 25 useful keys, so this takes seconds. The brute-force table does it for you and marks the shift whose letter counts are closest to typical English, using a chi-squared score. For the example text it picks shift 3.
- How is the most English-like shift chosen?
- For each shift the tool counts the 26 letters of the decoded text and compares them with the expected English share of each letter (E about 12.702%, T about 9.056%, Z about 0.074%). The score is the sum over letters of (observed − expected)² ÷ expected, so lower is closer to English. It needs enough letters: with fewer than 25 it can pick the wrong shift, and the table says so. Frequencies: Robert Lewand, Cryptological Mathematics (MAA, 2000): English letter frequencies, as tabulated in Wikipedia’s “Letter frequency”.
- Is the Caesar cipher secure?
- No. It has 25 keys and keeps the letter pattern of the language, so anyone can break it by hand or with this page. ROT13, ROT47 and Atbash have a single key and are not secrets at all. Vigenère is stronger but was broken in the 1800s. Use these for puzzles, games and teaching. To protect real data use modern encryption, a unique password from the password generator, and hashes (not ciphers) for checking data, as in the hash generator.
- What shift did Julius Caesar use?
- The Roman historian Suetonius writes that Caesar replaced each letter with the one three places further on, so A became D. That is the default shift of 3 here. In his Life of Augustus he adds that Augustus used a shift of one.
- What is ROT47, and how is it different from ROT13?
- ROT47 rotates the 94 printable ASCII characters from ! to ~ by 47 places, so digits and punctuation change too, and it is also its own inverse. “Hello, World!” becomes “w6==@[ (@C=5P”. Spaces, accented letters and emoji are kept.
- How does the Vigenère cipher work?
- Each letter is shifted by the next letter of a repeating key word (A = 0, B = 1 … Z = 25). Encoding ATTACKATDAWN with the key LEMON gives LXFOPVEFRNHR. Here the key moves on only when a letter or a shifted digit is converted, and spaces and punctuation are kept. It resists simple frequency counting but falls to Kasiski examination (1863) and related methods.
- What is the Atbash cipher?
- Atbash mirrors the alphabet: A becomes Z, B becomes Y and so on, so “Hello, World!” becomes “Svool, Dliow!”. The name comes from the Hebrew letters aleph, tav, bet and shin (first, last, second, second-last). Like ROT13 it is its own inverse and has no key.
- What happens to numbers, punctuation and accented letters?
- By default only the letters A to Z change. Digits are left alone unless you tick “Also shift digits”, which rotates 0 to 9 among themselves by the shift modulo 10 (a shift of 3 turns 2024 into 5357). Punctuation, spaces, accented letters such as é and emoji are never changed.
- Is my text sent anywhere?
- No. Everything runs in your browser and nothing you type is uploaded or saved. Reload the page and your text is gone.
How it works
Only the 26 ASCII letters are shifted, keeping their case: a letter at position p (A = 0) moves to (p ± shift) mod 26, forward to encode and back to decode, so any whole number works, negative or above 26. ROT13 is the same with a shift of 13. With “Also shift digits”, 0 to 9 move by the shift mod 10 (the key letter mod 10 for Vigenère; 0↔9, 1↔8 for Atbash). ROT47 adds 47 to the code of each character from ! (33) to ~ (126), wrapping inside those 94 characters. Atbash maps position p to 25 − p. Vigenère shifts each converted character by the next letter of the key, wrapping around the key, which keeps only A to Z letters from what you type. The brute-force table decodes with each of the 25 shifts. For each it counts the letters A to Z of the whole text (a shift only rotates those counts, so the text is counted once) and computes the chi-squared statistic against the expected English letter shares, Σ (observed − expected)² ÷ expected, where expected is the share of that letter times the number of letters. The expected shares are those of Lewand’s table, scaled to add up to exactly 100. The shift with the lowest score is marked most English-like; the text as typed is scored too, to catch text that is already English. The score is a statistical guess: texts under about 25 letters, names, abbreviations, code or other languages can be misjudged. Only the first 90 characters of each decoded line are previewed. Everything runs in your browser.
Sources
- Robert Lewand, Cryptological Mathematics (MAA, 2000): English letter frequencies, as tabulated in Wikipedia’s “Letter frequency”
- Suetonius, Life of Julius Caesar, section 56 (Caesar’s shift of three), LacusCurtius
- Pearson’s chi-squared test, Wikipedia
- ROT13, Wikipedia
- Vigenère cipher, Wikipedia
- Atbash, Wikipedia
More free tools
- Morse Code TranslatorTranslate text to Morse code and back, with audio at any WPM (Farnsworth too) and a full ITU-R M.1677-1 chart with punctuation, @ and SOS.
- Text to Binary ConverterConvert text to binary, hex, octal or decimal bytes and back. UTF-8 by default (é is 2 bytes, an emoji 4) or UTF-16, with a per-character breakdown.
- Hash GeneratorHash text or a file with SHA-256, SHA-1, SHA-384, SHA-512, MD5 and CRC32, add an HMAC key, and check a checksum. Runs in your browser; nothing is uploaded.
- Password GeneratorMake a strong random password or passphrase on your device: choose length and characters, see its strength in bits and copy it. Nothing is sent.
- Readability Score CheckerPaste English text for six readability scores: Flesch Reading Ease, Flesch-Kincaid, Gunning Fog, SMOG, Coleman-Liau and ARI. Runs in your browser.
- Find and ReplaceFind and replace text online: match case or whole words, use regular expressions with $1, run several pairs in order, and replace all or one by one.