Playfair encodes pairs of letters using a 5 × 5 square built from your key. Some messages need extra letters to form valid pairs. The tool shows both your original message and its prepared form, so you can see those changes before reading the result.
Build the keyed square
Start with an A–Z key, change J to I, and keep only the first appearance of each letter. Fill the rest of the square with unused alphabet letters. Here is the square for MONARCHY.
| Row | 1 | 2 | 3 | 4 | 5 |
|---|---|---|---|---|---|
| 1 | M | O | N | A | R |
| 2 | C | H | Y | B | D |
| 3 | E | F | G | I | K |
| 4 | L | P | Q | S | T |
| 5 | U | V | W | X | Z |
Prepare the pairs
- Remove nonletters and merge J into I, with the changes shown.
- Read letters in pairs. If both would match, insert X after the first and reconsider the second letter.
- When the repeated letter is X, insert Q instead.
- If a final letter has no partner, append X; if that final letter is X, append Q.
Follow the inserted filler
BALLOONKey MONARCHY; prepared plaintext BALXLOONIBSUPMNABALLOON becomes BA LX LO ON. The added X separates the two L letters into different pairs; it was not in the original word.
Transform each pair
- Same row: move each letter one cell right, wrapping at the edge.
- Same column: move each letter one cell down, wrapping at the bottom.
- Different row and column: take the other two corners of the rectangle, keeping each letter in its original row.
To decode, move left in a shared row or up in a shared column. The rectangle rule stays the same. IBSUPMNA decodes to BALXLOON. The tool leaves the X in place because removing every X could also remove a real letter from another message.
Try one yourself
With key MONARCHY, prepare XX before encrypting it. Why is XX not a valid prepared pair?