Type a keyword to build the 5×5 Playfair key square, then encrypt or decrypt any text. Every digraph is listed with the rule that was applied, and clicking a step lights up its letters on the square.
Last updated:
Key square
Click a step below to see its letters on the square.
Digraph steps
#
Pair
Positions (row, col)
Rule
Result
Advertisement
Advertisement
How to use the Playfair Cipher
Choose Encrypt or Decrypt at the top.
Enter the keyword, for example PLAYFAIR EXAMPLE. Repeated letters and non-letters are dropped and the rest of the alphabet fills the square.
Pick the variant: merge I and J (the classic choice) or omit Q, and set the filler letter if your puzzle uses something other than X.
Type or paste your text. The result updates instantly; press Encrypt text or Decrypt text to confirm and Copy result to copy it.
Study the steps: each row of the table shows the pair, its square positions, the rule and the output. Click a row to see it on the square.
The three Playfair rules
After the message is split into digraphs (pairs of letters), each pair is located in the key square and one of three rules is applied. Decryption simply runs the first two rules in the opposite direction; the rectangle rule is its own inverse.
Case
Encrypt
Decrypt
Example (key PLAYFAIR EXAMPLE)
Both letters in the same row
Take the letter to the right of each (wrap to the start of the row)
Take the letter to the left
EX → XM (row I R E X M)
Both letters in the same column
Take the letter below each (wrap to the top)
Take the letter above
DE → OD (column A E D O V)
Different row and column
Each letter moves along its own row to the other letter's column
Same as encrypt
HI → BM (corners of a rectangle)
Preparing the plaintext
Keep letters only and convert to capitals. Spaces, digits and punctuation are removed, which is why Playfair ciphertext is usually written in pairs or groups of five.
Apply the 25-letter rule: write J as I (or drop Q in the omit-Q variant).
Split into pairs from left to right. If a pair would contain the same letter twice, insert the filler after the first letter and continue from the second: TREE becomes TR EX E…
Pad the end with the filler if one letter is left over.
Because fillers are added during encryption, decrypted Playfair text often contains stray X letters, for example TREXESTUMP for TREES TUMP. Reading the result aloud usually makes the fillers obvious.
Tips for puzzles and classes
A valid Playfair ciphertext always has an even number of letters and never contains a pair such as AA; if yours does, the text was split wrongly or it is a different cipher.
No letter is ever encrypted to itself, and a pair and its reverse (AB and BA) always encrypt to reversed results. Codebreakers use both facts to test guesses.
Try longer, varied key phrases: a key such as MONARCHY fills the first rows with distinct letters and changes every rule outcome.
For a cipher that keeps spaces and is easier to start with, try the Caesar cipher, or move on to the polyalphabetic Vigenère cipher.
Frequently asked questions
How does the Playfair cipher work?
The keyword fills a 5×5 square, followed by the unused letters of the alphabet. The message is split into pairs of letters. If both letters are in the same row, each is replaced by the letter to its right; in the same column, by the letter below; otherwise they form a rectangle and each is replaced by the letter in its own row at the other letter's column.
Why are I and J combined?
A 5×5 square has room for only 25 letters, so one letter of the 26-letter alphabet must go. The usual convention writes J as I. Some puzzles omit Q instead because it is rare; choose Omit Q if your key square has no Q.
Why does the ciphertext contain extra X letters?
Playfair cannot encrypt a pair made of the same letter, so a filler (usually X) is inserted between doubled letters, as in BALLOON becoming BA LX LO ON. A filler is also added when the message has an odd number of letters. When the filler itself is doubled, a second filler such as Q is used.
How do I decrypt a Playfair cipher?
Select Decrypt, enter the same keyword and paste the ciphertext. The rules are reversed: same row takes the letter to the left, same column takes the letter above, and rectangles swap columns as before. The tool then removes fillers that sit between two identical letters and at the very end; untick the option to see the raw output.
Is my keyword example correct?
With the keyword PLAYFAIR EXAMPLE, the text HIDE THE GOLD IN THE TREE STUMP encrypts to BMODZBXDNABEKUDMUIXMMOUVIF. This is the standard textbook example and it is loaded by default so you can check your settings.
Is the Playfair cipher secure?
No. It was used for tactical messages in the late 1800s and early 1900s because it is quick by hand, but it can be broken with digraph frequency analysis and modern hill-climbing solvers. Use it for puzzles, escape rooms and learning, and modern encryption such as AES for real secrets.
Is my text sent anywhere?
No. The key square and all encryption and decryption are computed in JavaScript in your browser. Nothing you type is uploaded.
Are all the tools on FreeToolCabin tested for quality and accuracy?
Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.