Last updated
ROT13 Cipher Examples
The ROT13 Cipher tool encodes and decodes text using the ROT13 substitution cipher. Below are examples of encoding, decoding, and the cipher's common uses.
How ROT13 Works
Each letter is replaced by the letter 13 positions later in the alphabet:
Original: A B C D E F G H I J K L M
Encoded: N O P Q R S T U V W X Y Z
Original: N O P Q R S T U V W X Y Z
Encoded: A B C D E F G H I J K L M
Key property: applying ROT13 twice returns the original text.
Encoding and decoding are the same operation.
Decoding — Same Operation
Decode the same ROT13 text by applying ROT13 again:
Input: Gur ohgyre qvq vg.
Output: The butler did it.
ROT13 is its own inverse — encode and decode are identical.
Case Preservation
ROT13 preserves the case of each letter:
Input: Hello, World!
Output: Uryyb, Jbeyq!
Uppercase H → U
Lowercase e → r
Lowercase l → y
Lowercase l → y
Lowercase o → b
(comma and space unchanged)
Uppercase W → J
Lowercase o → b
Lowercase r → e
Lowercase l → y
Lowercase d → q
(! unchanged)
Non-Alphabetic Characters Unchanged
Numbers, spaces, and punctuation pass through unmodified:
Input: "Score: 42/100 — Amazing!"
Output: "Fpber: 42/100 — Nznmvat!"
Numbers (42, 100), punctuation (: / —), and spaces are unchanged.
Only letters are rotated.
Spoiler Hiding (Common Use Case)
Hide a movie spoiler in an online forum post:
Original spoiler:
Darth Vader is Luke's father.
ROT13 encoded:
Qnegu Inqre vf Yhxr'f sngure.
Forum post:
"Great movie! ROT13 spoiler below:
Qnegu Inqre vf Yhxr'f sngure."
Readers who want to see the spoiler decode it with ROT13.
Puzzle Answer Hiding
Hide a puzzle answer so readers can choose to reveal it:
Puzzle: What has keys but no locks, space but no room?
Answer (hidden): N xrlobneq
Decoded: A keyboard
Caesar Cipher — Other Rotations
ROT13 is a special case of the Caesar cipher. Other rotations:
ROT1 (shift by 1): Hello → Ifmmp
ROT3 (Caesar): Hello → Khoor
ROT13 (self-inverse):Hello → Uryyb
ROT25 (shift by 25): Hello → Gdkkn
ROT13 is unique because applying it twice returns the original.
No other rotation (except ROT0) has this property with a 26-letter alphabet.
Full Substitution Alphabet — ROT13
Plain: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Cipher: N O P Q R S T U V W X Y Z A B C D E F G H I J K L M
Frequency Analysis — Why ROT13 Is Not Secure
ROT13 is trivially broken by frequency analysis:
English letter frequency (most common):
E T A O I N S H R D L C U M W F G Y P B V K J X Q Z
ROT13 shifts the frequency distribution by 13 positions.
The most common letter in ROT13 English text is R (which decodes to E).
Example analysis:
Encoded text: "Gur dhvpx oebja sbk whzcf bire gur ynml qbt"
Most frequent letter: r (appears 3 times)
r → e in ROT13 → confirms it's ROT13 encoded English
ROT13 provides NO security. Use it only for spoiler hiding,
never for protecting sensitive information.
Implement ROT13 in common languages:
JavaScript:
function rot13(str) {
return str.replace(/[a-zA-Z]/g, (c) => {
const base = c <= 'Z' ? 65 : 97;
return String.fromCharCode(((c.charCodeAt(0) - base + 13) % 26) + base);
});
}
rot13("Hello"); // "Uryyb"
Python:
import codecs
codecs.encode("Hello", "rot_13") # "Uryyb"
# Or manually:
"Hello".translate(str.maketrans(
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz',
'NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm'
))
Historical Context
ROT13 in the context of cipher history:
Caesar cipher (shift 3, ~50 BC):
A → D, B → E, C → F ...
Used by Julius Caesar for military communications
ROT13 (shift 13, modern):
A → N, B → O, C → P ...
Popularized on Usenet newsgroups in the 1980s
Used for spoilers and mildly offensive content
Both are trivially broken by frequency analysis.
Modern encryption (AES, RSA) is exponentially more complex.
- Encode and decode text with ROT13 instantly
- Same operation for encoding and decoding (self-inverse)
- Preserves case and leaves non-alphabetic characters unchanged
- Supports other Caesar cipher rotations (ROT1 through ROT25)
- Shows the full substitution alphabet for any rotation
- Demonstrates frequency analysis to show why ROT13 is not secure
- Common uses: spoiler hiding, puzzle answers, forum posts
Basic Encoding Example
Encode a spoiler warning:
Input: The butler did it.
Output: Gur ohgyre qvq vg.
Letter-by-letter:
T → G
h → u
e → r
(space unchanged)
b → o
u → h
t → g
l → y
e → r
r → e
(space unchanged)
d → q
i → v
d → q
(space unchanged)
i → v
t → g
. → . (unchanged)