ROT13 Cipher Encoder/Decoder
Last updated: 19 August 2026
Reviewed by Gavin · Research and drafting assisted by AI
Uryyb, Jbeyq!
ROT13 letter mapping (A–M)
Each letter maps to the letter 13 positions ahead in the alphabet. N–Z map back to A–M. Same logic for lowercase. Numbers and punctuation are unchanged.
Worked examples (hand-verified)
| Input | ROT13 output |
|---|---|
| Hello | Uryyb |
| Hello, World! | Uryyb, Jbeyq! |
| ABCDEFGHIJKLM | NOPQRSTUVWXYZ |
| abcdefghijklm | nopqrstuvwxyz |
| 123 456 | 123 456 |
| A | N |
ROT13 is not encryption — it is a simple substitution cipher with no key. Use it for hiding spoilers, not for protecting sensitive data.
ROT13 Cipher Encoder/Decoder
ROT13 is one of the simplest and most recognisable ciphers in the world. It shifts every letter in the Latin alphabet by exactly 13 positions, turning A into N, B into O, and N back into A. Because 13 is exactly half of 26, applying ROT13 twice returns the original text, which is why the same operation functions as both encoder and decoder. This tool runs the cipher in your browser, accepts any text, leaves digits and punctuation unchanged, and updates the result as you type.
The cipher dates back to the broader family of Caesar shifts, which Julius Caesar used around 50 BC to obscure military messages. Suetonius records in De Vita Caesarum that Caesar shifted the letters of his dispatches by three positions, which is the cipher most people call "the Caesar cipher" today. Any fixed shift from 1 to 25 produces a different Caesar cipher. ROT13 is the special case where the shift equals half the alphabet, giving the cipher its self-inverse property. Unicode adopted ROT13 in the early 1980s as a standard way to obscure plot spoilers and offensive content in newsgroup posts, and the convention spread to early internet forums, BBS systems, and eventually Reddit, which still uses it for spoiler tags today.
Despite its age, ROT13 has not disappeared. It is a teaching example in cryptography courses, a quick text-obfuscation trick in programming, and the lingua franca for hiding spoilers online. If you have ever seen a movie title written as "Jungle Cub" on Reddit, the author was almost certainly using ROT13 to keep the surprise intact for anyone who did not want the answer handed to them.
How to Use the ROT13 Encoder/Decoder
- Type or paste any text into the input box at the top of the tool.
- The ROT13 output appears in the second box as you type. Letters A-Z and a-z are rotated by 13; digits, punctuation, whitespace, and newlines pass through unchanged.
- Click the Copy button to copy the encoded output to your clipboard.
- To decode, click Swap. The output moves back into the input, and the next refresh shows the original plaintext, because ROT13 is self-inverse, no separate decode step is needed.
- Use the Clear button to wipe the input and start fresh.
The worked-examples table below the output box shows six hand-verified test cases so you can confirm the cipher is behaving correctly: "Hello" becomes "Uryyb", "Hello, World!" becomes "Uryyb, Jbeyq!", and digits like "123" pass through unchanged.
The ROT13 Algorithm
ROT13 is a single-step letter substitution with a fixed shift of 13. For every uppercase letter, the new character is computed as:
c' = ((c - 'A' + 13) mod 26) + 'A'
For lowercase letters, the same expression is used with 'a' instead of 'A':
c' = ((c - 'a' + 13) mod 26) + 'a'
The modulo 26 keeps the result within the alphabet range. The plus 13 advances the letter by half the alphabet, and the mod 26 wraps around from Z back to A. Digits, punctuation, marks, spaces, and newlines are not in the range 65 to 90 or 97 to 122, so they pass through untouched.
The JavaScript implementation is therefore small enough to fit in one function. The tool walks the input string character by character, classifies each code point by range, and writes the shifted letter or the original character to the output. There is no key, no table, no table-lookup, no state. Given the same input, the output is always identical.
Why ROT13 is Self-Inverse
ROT13 has a unique property among Caesar shifts: it equals its own inverse. The mathematical reason is that two shifts of 13 equal one shift of 26, and 26 mod 26 equals 0, so:
ROT13(ROT13(x)) = ((x + 13 + 13) mod 26) = (x + 26) mod 26 = x
This is why the same tool works for both encoding and decoding. You do not need a separate "decode" button, you simply run the cipher again and you recover the plaintext. The same self-inverse property appears in Atbash (the Hebrew alphabet reversal cipher), but ROT13 is the most widely used self-inverse cipher in modern Western text.
Worked Examples
Example 1, a single word. The word "Hello" rotates letter by letter. H shifts 13 places to U. E shifts to R. L shifts to Y. L shifts to Y again. O shifts to B. The output is "Uryyb". Because ROT13 is self-inverse, "Uryyb" re-encodes back to "Hello".
Example 2, full alphabet rotation. The complete uppercase alphabet "ABCDEFGHIJKLMNOPQRSTUVWXYZ" becomes "NOPQRSTUVWXYZABCDEFGHIJKLM". Notice how the alphabet splits cleanly in half: the first 13 letters (A-M) map to the second 13 (N-Z), and the second 13 map back to the first. Lowercase letters "abcdefghijklmnopqrstuvwxyz" follow the same rule.
Example 3, punctuation and digits unchanged. The phrase "Hello, World!" contains a comma, a space, and an exclamation mark. Only the letters are rotated, so the output is "Uryyb, Jbeyq!". The comma, space, and exclamation remain in their original positions. The string "123" contains no letters, so it becomes "123" with no change. The string "Hello123" becomes "Uryyb123", the letters rotate, the digits stay put.
Example 4, full sentences with mixed content. "The quick brown fox jumps over the lazy dog" rotates to "Gur dhvpx oebja sbk whzcf bire gur ynml qbt". Every letter is shifted, every space and punctuation mark is preserved. Try running the output back through the tool, you recover the original sentence, demonstrating the self-inverse property on a longer string.
Example 5, Unicode and accented characters. The Unicode strings "café" and "résumé" are not affected by ROT13. Standard ROT13 only touches the ASCII letters A-Z and a-z. Accented characters like é, ü, or ñ are not in those ranges, so they pass through unchanged. If you need to obscure accented text, ROT13 is not the right tool, consider ROT47 or a Unicode-aware encoding instead.
Where ROT13 Shows Up
Usenet and Reddit spoiler tags. The original use case. Before spoiler warnings and HTML
/r/SpoilerTags subreddit and the built-in spoiler-tag feature still use ROT13 in many places to give the reader a single click to reveal hidden text.Email obfuscation. Many websites publish email addresses as ROT13-encoded text inside the HTML, then decode them with a tiny JavaScript snippet. The intent is to make the address invisible to dumb email-scraping bots that just regex the raw HTML. Modern scrapers catch up, but the technique still slows down casual scraping.
Cryptography puzzles and CTF challenges. Beginner capture-the-flag competitions include ROT13 as the first cipher to crack. Most "decode this message" clues in puzzle books and classroom activities are ROT13. Learning to recognise the telltale signs of ROT13 (mostly nonsense text with no digits or punctuation changed) is a rite of passage in the cryptography community.
Programming and code-of-conduct strings. Programmers occasionally use ROT13 to obfuscate profanity-filtered strings in source code, jokes in easter eggs, or strings that should stay hidden until runtime. The Unix command tr 'A-Za-z' 'N-ZA-Mn-za-m' is the canonical one-liner for ROT13 and has been part of the BSD distribution since the 1980s.
Teaching classical cryptography. ROT13 is the most common first example in any introduction to cryptography because it captures the essential idea of substitution ciphers without the complexity of a key. Students learn about monoalphabetic substitution, frequency analysis, and the importance of a key by breaking ROT13 by hand.
Online forums and comment threads. Beyond Reddit, smaller forums and discussion boards still use ROT13 in spoiler tags, puzzle threads, and inline code samples. The most common tell is a sentence that almost looks like English but every letter is 13 positions off.
Reddit's r/Unexpected and similar joke subs. Some communities use ROT13-encoded titles as a meta-joke, the title is unreadable until you decode it, and the joke only works once you do.
Common Mistakes
Mistaking ROT13 for encryption. ROT13 is a substitution cipher, not encryption. It has no key, no password, and no secret. A 7-year-old with a pen and paper can decode it in under a minute, and any computer can decode it in under a millisecond. Use ROT13 to hide spoilers, jokes, and other content readers can opt out of. Do not use it for passwords, personal data, or anything that needs to stay confidential.
Applying ROT13 only once when you meant twice. Some tools and utilities apply ROT13 twice in a row, which cancels out and returns the original. This is a common bug in older code that encodes strings for storage. If you suspect a double-ROT13, try a single application and see if the result is readable.
Confusing ROT13 with ROT5 or ROT47. ROT5 is the same idea applied to digits, 0 maps to 5, 1 to 6, and so on. ROT47 is a broader variant that shifts 94 printable ASCII characters (codes 33 through 126) by 47. If you see encoded text where digits or punctuation are also rotated, you are looking at ROT5 or ROT47, not ROT13. The "ROT-18" combined cipher applies ROT13 to letters and ROT5 to digits in the same pass.
Treating ROT13 as a Unicode cipher. Standard ROT13 only touches the ASCII letters A-Z and a-z. Accented characters, Cyrillic, Greek, Han characters, and emoji are not affected. If you need to obscure Unicode text, ROT13 is the wrong tool. Look for a Unicode-aware cipher or a general-purpose encoding like Base64.
Forgetting ROT13 touches case. A and a are different letters in the alphabet, and ROT13 keeps them in separate streams. The result is "a" → "n" and "A" → "N", both valid shifts. If you accidentally uppercase the input before passing it through ROT13, you still get the right answer, case is preserved because the two ranges are shifted independently.
Reading ROT13 output as a real cipher. When you see ROT13 text in the wild, decode it with a tool before deciding it is gibberish. "Jungle Cub" looks like nonsense until you remember it is "Whisper Cub" backwards. Always assume ROT13 text is meaningful until proven otherwise.
Frequently Asked Questions
Question? What is ROT13 in one sentence? ROT13 is a Caesar cipher that shifts every letter by 13 positions and leaves digits, punctuation, and whitespace unchanged. Because 13 is half the alphabet, applying ROT13 twice returns the original text.
Question? Is ROT13 the same as the Caesar cipher? ROT13 is a special case of the Caesar cipher where the shift equals 13. The Caesar cipher includes any fixed shift from 1 to 25, so ROT13 is one member of the broader family. Julius Caesar himself used shift 3, not 13.
Question? Why is ROT13 used for spoilers? ROT13 is symmetrical, the same operation encodes and decodes, so a reader who wants to see the spoiler can decode it instantly, while a casual scroller sees only gibberish. The convention started on Usenet in the early 1980s and has persisted because it requires no special markup, no plugins, and no client-side logic.
Question? Can ROT13 hide my email address? Yes, ROT13 is a lightweight way to obscure email addresses from dumb scrapers. Most modern bots know how to decode ROT13, so do not rely on it for serious protection. Use email obfuscation services or reCAPTCHA for higher security.
Question? What is the difference between ROT13 and ROT47? ROT13 touches only the letters A-Z and a-z (52 characters). ROT47 touches 94 printable ASCII characters (codes 33 through 126), which includes digits, punctuation, and symbols. Use ROT47 when you need to obscure digits or punctuation.
Question? How do I decode ROT13 by hand? Draw the alphabet in a circle, then shift each letter 13 positions forward (or backward, the result is the same). The trick is recognising when text is ROT13 in the first place: look for sentences with mostly nonsense words, no obvious preserved digits, and punctuation in the right places. With practice, you can decode ROT13 in your head.
Question? Is ROT13 secure? No. ROT13 has no key, so its security is zero. Anyone who knows the cipher can decode any ROT13 text in seconds. It is a teaching tool and a spoiler tag, not a security mechanism.
Question? Does ROT13 work on numbers? No. Standard ROT13 only touches letters. Numbers, punctuation, and whitespace pass through unchanged. To obscure digits, use ROT5 or ROT47.
Question? Why does ROT13 only affect letters? The cipher is defined as a substitution of the 26-letter Latin alphabet. Numbers and punctuation are not part of the alphabet, so the cipher leaves them alone. This is by design, ROT13 is for text, not for binary data.
References
- Suetonius, De Vita Caesarum (c. 121 AD): the original Roman description of Caesar's 3-position shift cipher, which is the historical ancestor of ROT13.
- David Kahn, The Codebreakers (1996): the canonical history of classical cryptography, including the Caesar cipher and its modern variants.
- Dennis Ritchie and Ken Thompson, Unix Man Page: tr(1) (1971): documentation of the original Unix
trcommand, which has included ROT13 since the early BSD releases. - RFC 20: ASCII format for Network Interchange (1969): the standard that defines the English alphabet code points ROT13 operates on.
- Wikipedia, "ROT13" (current revision): the community-maintained reference for ROT13, including its history, variants, and modern uses.