What ROT13 is and why it is self-inverse
ROT13 is a Caesar cipher with a shift of thirteen. Each letter is replaced by the letter thirteen positions later in the alphabet, wrapping around from Z back to A: A becomes N, B becomes O, and N becomes A again. Hello, World! becomes Uryyb, Jbeyq! with punctuation, digits and spacing left exactly as they were.
Thirteen is half of twenty-six, which gives ROT13 its defining property: applying it twice returns the original text. There is no separate decode operation, because encoding and decoding are the same function. That is why tools and mail clients historically offered a single rot13 command rather than an encrypt and a decrypt pair.
This tool generalises to any shift from 0 to 25, so it also handles classic Caesar variants such as ROT5 and the single-shift puzzles that appear in capture-the-flag challenges. The alphanumeric mode additionally rotates digits by the same amount modulo ten, so with a shift of thirteen the digits move by three: 2025 becomes 5358. That combination is sometimes labelled ROT13.5 or ROT18.
ROT13 provides no security whatsoever
This needs stating plainly. ROT13 has no key. The transformation is fixed and public, so there is no secret for an attacker to guess and nothing to brute force. Anyone who recognises the output, and it is highly recognisable, can reverse it by running the same operation again. Even for an arbitrary Caesar shift there are only 25 possibilities, all of which a person can try by hand in under a minute and a script can try instantly.
It is therefore not encryption, not obfuscation of any practical strength, and not a way to protect anything. Never use it for passwords, API keys, personal data, or any content whose disclosure would matter. Rotating a string before storing it provides exactly the same protection as storing it in the clear, while creating a false impression that something was done.
For actual confidentiality use a real algorithm with a real key: AES-GCM or ChaCha20-Poly1305 for symmetric encryption, and a password-based key derivation function such as Argon2id or scrypt if the key comes from a passphrase. If you only need to make text safe for transport rather than secret, base64 is the honest choice, since nobody mistakes it for protection.
Where ROT13 is genuinely used
Its real purpose has always been social rather than cryptographic: hiding text from casual reading rather than from an adversary. On Usenet it was the convention for spoilers, punchlines and offensive jokes, so a reader had to make a deliberate choice to decode before seeing the content. That convention survives in forum posts, puzzle hunts and crossword discussion.
It also appears as a light deterrent against automated scanning. Rotating an email address or a keyword in page source stops the most naive scrapers and pattern matchers, though anything more sophisticated than a regular expression defeats it immediately. Treat this as noise reduction, not protection.
In teaching and in puzzles it earns its place. ROT13 is the smallest possible worked example of a substitution cipher, of modular arithmetic applied to text, and of a function that is its own inverse, which makes it a common first exercise in a cryptography course and a common warm-up stage in a capture-the-flag challenge.
What the transformation leaves untouched
Only the 26 ASCII letters in each case are rotated. Case is preserved, so an uppercase letter maps to an uppercase letter and lowercase to lowercase. Spaces, punctuation, line breaks and any character outside the basic Latin alphabet pass through unchanged, which is why accented letters, Cyrillic, Greek, CJK characters and emoji come out of the tool exactly as they went in.
That pass-through behaviour is what makes ROT13 output so easy to recognise. Word lengths, capitalisation, apostrophes and sentence punctuation all survive, so the shape of the text is intact and a reader can often identify short words such as a, I and the by pattern alone. Frequency analysis on anything longer than a sentence identifies the shift immediately.
The digit handling in alphanumeric mode is a separate rotation modulo ten rather than an extension of the letter alphabet, so letters and digits never map into each other. Note that the round trip differs between the two alphabets: applying a shift of 13 twice returns every letter to its original but moves digits by six, so use the complementary shift when digits have to round-trip exactly.