ROT13 is a substitution cipher that shifts each letter 13 positions forward in the alphabet. 'A' becomes 'N', 'B' becomes 'O', and so on—wrapping around so 'N' becomes 'A', 'O' becomes 'B'. The number 13 is chosen because the English alphabet has 26 letters, making ROT13 its own inverse: applying the transformation twice returns the original text. Encoding 'HELLO' produces 'URYYB', and encoding 'URYYB' produces 'HELLO'. This self-inverse property simplifies implementation—a single function both encodes and decodes.
ROT13 is a specific case of the Caesar cipher (named after Julius Caesar who used it for military messages), where the shift is always 13 instead of variable offsets like 1, 3, or 12. Unlike modern encryption, ROT13 is trivially broken—anyone knowing the algorithm can decode it instantly without keys or passwords. It provides zero cryptographic security and is never used for protecting sensitive data. Instead, ROT13 serves as a simple obfuscation tool for hiding spoilers, puzzle answers, or offensive text from casual readers while keeping it easily reversible.
The transformation affects only letters (A-Z, a-z) and preserves case, leaving numbers, punctuation, and spaces unchanged. 'Hello, World!' encodes to 'Uryyb, Jbeyq!' with the comma, space, and exclamation point remaining intact. This behavior ensures that text structure is maintained, making ROT13-encoded messages still readable in terms of word boundaries and formatting. Non-Latin scripts (Chinese, Arabic, emoji) are unaffected by ROT13 because they are not part of the A-Z alphabet.