Skip to main content
ponderloop

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.

Method
Direction

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).

Your text decoded with each Caesar shift from 1 to 25, with its English-likeness score
ShiftDecoded textχ² score
Shift 1Vjg swkem dtqyp hqz lworu qxgt vjg ncba fqi.626.7
Shift 2Uif rvjdl cspxo gpy kvnqt pwfs uif mbaz eph.141.8
Shift 3Most English-likeThe quick brown fox jumps over the lazy dog.109.3
Shift 4Sgd pthbj aqnvm enw itlor nudq sgd kzyx cnf.203.4
Shift 5Rfc osgai zpmul dmv hsknq mtcp rfc jyxw bme.132.0
Shift 6Qeb nrfzh yoltk clu grjmp lsbo qeb ixwv ald.214.4
Shift 7Pda mqeyg xnksj bkt fqilo kran pda hwvu zkc.251.2
Shift 8Ocz lpdxf wmjri ajs ephkn jqzm ocz gvut yjb.696.1
Shift 9Nby kocwe vliqh zir dogjm ipyl nby futs xia.122.9
Shift 10Max jnbvd ukhpg yhq cnfil hoxk max etsr whz.271.3
Shift 11Lzw imauc tjgof xgp bmehk gnwj lzw dsrq vgy.303.4
Shift 12Kyv hlztb sifne wfo aldgj fmvi kyv crqp ufx.156.3
Shift 13Jxu gkysa rhemd ven zkcfi eluh jxu bqpo tew.232.3
Shift 14Iwt fjxrz qgdlc udm yjbeh dktg iwt apon sdv.172.7
Shift 15Hvs eiwqy pfckb tcl xiadg cjsf hvs zonm rcu.129.2
Shift 16Gur dhvpx oebja sbk whzcf bire gur ynml qbt.136.9
Shift 17Ftq cguow ndaiz raj vgybe ahqd ftq xmlk pas.351.8
Shift 18Esp bftnv mczhy qzi ufxad zgpc esp wlkj ozr.694.9
Shift 19Dro aesmu lbygx pyh tewzc yfob dro vkji nyq.129.5
Shift 20Cqn zdrlt kaxfw oxg sdvyb xena cqn ujih mxp.480.4
Shift 21Bpm ycqks jzwev nwf rcuxa wdmz bpm tihg lwo.251.7
Shift 22Aol xbpjr iyvdu mve qbtwz vcly aol shgf kvn.156.7
Shift 23Znk waoiq hxuct lud pasvy ubkx znk rgfe jum.315.4
Shift 24Ymj vznhp gwtbs ktc ozrux tajw ymj qfed itl.376.4
Shift 25Xli uymgo fvsar jsb nyqtw sziv xli pedc hsk.177.3

The ciphers compared on “Hello, World!”

Every result is computed by the tool. “Keys” counts the settings worth trying: shift 0 and shift 26 leave the text as it is.
CipherSettingResultKeysSame both ways
Caesar shiftShift 3Khoor, Zruog!25No (decode shifts back)
Caesar shiftShift 1Ifmmp, Xpsme!25No (decode shifts back)
ROT13Shift 13Uryyb, Jbeyq!1Yes
ROT47Shift 47 of 94 charactersw6==@[ (@C=5P1Yes
AtbashA↔Z, B↔YSvool, Dliow!1Yes
VigenèreKey LEMONSixzb, Hsdzq!26 to the power of the key lengthNo (decode subtracts the key)

Alphabet under ROT13, Atbash and a shift of 3

Each plain letter and what it becomes. ROT13 and Atbash read the same in both directions; for the Caesar column, decoding runs the table backwards.
PlainROT13AtbashCaesar +3
ANZD
BOYE
CPXF
DQWG
ERVH
FSUI
GTTJ
HUSK
IVRL
JWQM
KXPN
LYOO
MZNP
NAMQ
OBLR
PCKS
QDJT
REIU
SFHV
TGGW
UHFX
VIEY
WJDZ
XKCA
YLBB
ZMAC

English letter frequencies used for the score

Share of all letters in typical English text, most common first. Source: Robert Lewand, Cryptological Mathematics (MAA, 2000): English letter frequencies, as tabulated in Wikipedia’s “Letter frequency”.
RankLetterShare of lettersExpected in 100 letters
1E12.702%12.7
2T9.056%9.1
3A8.167%8.2
4O7.507%7.5
5I6.966%7.0
6N6.749%6.7
7S6.327%6.3
8H6.094%6.1
9R5.987%6.0
10D4.253%4.3
11L4.025%4.0
12C2.782%2.8
13U2.758%2.8
14M2.406%2.4
15W2.36%2.4
16F2.228%2.2
17G2.015%2.0
18Y1.974%2.0
19P1.929%1.9
20B1.492%1.5
21V0.978%1.0
22K0.772%0.8
23J0.153%0.2
24X0.15%0.2
25Q0.095%0.1
26Z0.074%0.1

How to encode or decode a Caesar cipher

  1. 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.
  2. 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.
  3. 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.
  4. 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

All text & filesAll toolsHome & DIY calculators