Playfair Cipher
Playfair cipher encrypts or decrypts letter pairs using your visible key-generated 5×5 square. This version merges J into I and keeps fillers on decryption; it cannot recover original J spelling or determine which fillers to remove.
Current key square: J is represented by I.
| P | L | A | Y | F |
| I | R | E | X | M |
| B | C | D | G | H |
| K | N | O | Q | S |
| T | U | V | W | Z |
No prepared input yet.
Ready. Supply the key phrase used for the message.
Key square and alphabet
The key square updates as you edit the key phrase. Uppercase the key, remove whitespace, replace J with I, keep each letter at its first occurrence, then append unused letters in ABCDEFGHIKLMNOPQRSTUVWXYZ order. Fill the square left to right, top to bottom. This compresses 26 English letters into 25 cells by merging I/J. Original J spelling cannot be reconstructed from the ciphertext alone.
Preparing pairs and fillers
Uppercase the input, remove whitespace and replace J with I. Read two letters at a time. If both are the same, insert X after the first letter and reconsider the second letter in the next pair. When that first letter is X, use Q instead, avoiding an XX pair. A final unpaired letter gets X, or Q when that letter is X. The tool displays the exact prepared pairs before encryption.
Same row, same column and rectangle
If a pair lies in one row, encryption moves each letter one cell right, wrapping at the edge; decryption moves left. If it lies in one column, encryption moves each letter one cell down, wrapping; decryption moves up. Otherwise each letter keeps its row and takes the other letter’s column: the other corners of the rectangle. Keep the order of the pair.
Decryption does not guess the original text
Decryption requires an even number of letters and the correct supplied key. It adds no padding. It returns prepared uppercase text with fillers still present. An X or Q may be a genuine original letter, so this page does not automatically remove it. Case, whitespace and original J spelling are not recovered. It does not guess keys, identify a cipher or perform automatic cracking.
Independently computed pair checks
We calculated these four inputs with a separate Python implementation and this page’s JavaScript. Prepared text, squares and ciphertext matched; both implementations decoded the ciphertext back to the prepared text. The third sample covers same-row, same-column and rectangle paths. The fourth checks the J merge and a final X requiring a Q filler. We also checked every distinct letter pair in one generated square. This table was generated from the calculations, not copied from another converter.
| Key phrase | Original text | Prepared plaintext | Computed ciphertext | Decoded prepared text |
|---|---|---|---|---|
| PLAYFAIR EXAMPLE | HIDE THE GOLD IN THE TREE STUMP | HIDETHEGOLDINTHETREXESTUMP | BMODZBXDNABEKUDMUIXMMOUVIF | HIDETHEGOLDINTHETREXESTUMP |
| MONARCHY | BALLOON | BALXLOON | IBSUPMNA | BALXLOON |
| ABCDE | AB AF AG | ABAFAG | BCFLBF | ABAFAG |
| KEYWORD | JX X | IXXQ | QWWX | IXXQ |
To reproduce a row, supply its key phrase, encrypt its original text, compare the displayed prepared pairs, then press Reverse result. Compare decryption with the prepared plaintext column, not the original formatting or spelling.
Input, output and limits
Enter one English-letter text with optional whitespace, up to 20,000 input characters per run. Key phrases accept 1–1,000 characters containing English letters and whitespace, with at least one letter. Digits, punctuation, accented letters and emoji are rejected rather than silently removed. Input text follows the same English-letter rule. Decrypted ciphertext must have an even letter count after whitespace removal and J normalization.
Output is uppercase text with one-click copy. Encryption may add filler letters; the prepared sequence may therefore be longer than the input letters. One input per run; no login, registration, uploads, batch mode, saved history or daily counter. Processing stays in your browser.
Does Playfair protect confidential information?
No. Use this historical cipher for learning and puzzles, not protection of secrets. This page applies your supplied key and makes no claim to recover a message without it.
Related classic tools
Caesar and ROT13 use shifts, Atbash reverses the alphabet, Vigenere applies repeated key shifts, Pigpen uses symbols, Substitution Cipher applies one alphabet mapping, and Bacon Cipher uses A/B groups. Cipher Decoder displays alternatives without identification. This page uses key-square letter pairs.
Related representation walkthrough
This existing video demonstrates hexadecimal input and Base64 output, not Playfair key recovery.
Loading the player connects to YouTube and shares connection information such as your IP address and playback requests.
For position rearrangement rather than letter substitution, use the Rail fence transposition tool.
For candidate families based on stated features rather than decoded results, use the Cipher feature candidate tool.