Playfair Cipher
Encrypt and decrypt Playfair cipher text with any keyword, a live 5×5 key square and visible digraphs.
Key square
J is written as I, so the 25 cells hold every other letter.
Digraphs
How it works
Puzzle & teaching toy. The Playfair cipher was broken over a century ago and offers no real security — use it for crosswords, escape rooms, geocaching and classroom demos, never for anything private. Everything runs locally in your browser; nothing is uploaded.
The Playfair cipher, invented by Charles Wheatstone in 1854, encrypts pairs of letters (digraphs) instead of single letters. Your keyword fills a 5×5 square — duplicate letters dropped — and the rest of the alphabet follows, with I and J sharing a cell so 25 letters fit. The text is stripped to letters and split into pairs; a filler letter (X by default) is pushed between doubled letters and appended if the last pair is short.
Each pair is then swapped by three rules: letters in the same row shift one place right, letters
in the same column shift one place down, and otherwise each letter moves to the corner of the
rectangle sitting in its own row. Decryption reverses this — left, up, and the same rectangle
rule. This tool uses the standard J-into-I variant by default; switch to the "Omit Q" alphabet if
your puzzle uses that convention. Fillers stay visible after decryption, which is why a decrypted
message often reads TREXES instead of TREES.
All of the work happens in your browser with plain JavaScript — no keys, no accounts, no server. Playfair is a historical, hand-worked cipher: treat it as a puzzle, not as encryption.
Frequently asked questions
How does the Playfair cipher work?
Your keyword fills a 5×5 square (duplicate letters dropped) and the rest of the alphabet follows, with I and J sharing one cell. The message is stripped to letters and split into pairs, with a filler letter inserted between doubled letters and appended if the last pair is short. Letters in the same row shift one place right, letters in the same column shift one place down, and any other pair swaps to the opposite corners of the rectangle they form, each letter staying in its own row. Decryption shifts left and up instead.
Why do I and J share a cell, and what if my puzzle omits Q?
A 5×5 square holds only 25 cells but the alphabet has 26 letters, so one letter must go. The standard convention writes J as I, which this tool uses by default. Some puzzles drop Q instead — switch the Alphabet setting to "Omit Q" and I and J stay separate. Pick whichever variant the puzzle you are solving was built with, because the two produce different ciphertext.
Is the Playfair cipher secure?
No. Playfair is a 19th-century hand cipher that was already being broken during the First World War, and a few hundred letters of ciphertext are enough for frequency analysis on digraphs to crack it. Treat it as a puzzle and teaching toy for crosswords, escape rooms, geocaching and classroom demos — never for anything private. For real protection use modern authenticated encryption such as AES-GCM.