Skip to main content

Playfair Cipher

Encode and decode text using the classic Playfair cipher — a 5x5 keyword grid that substitutes letter pairs (digraphs) instead of single letters. Supports the standard I/J-shared grid or an Omit-Q variant, with a configurable filler letter.

Input

Alphabetic characters only. Duplicate letters are removed when building the 5x5 grid.

Playfair uses a 5x5 grid, which only fits 25 letters — pick which letter is folded or dropped.

Used to separate doubled letters within a pair and to pad an odd-length message.

Output

Result
Was this helpful?

Guides

What is the Playfair cipher?

The Playfair cipher is a manual digraph substitution cipher — instead of encrypting one letter at a time like the Caesar or Atbash ciphers, it encrypts letters in pairs. Invented in 1854 by Charles Wheatstone but named after Lord Playfair, who championed its use, it served as a British military field cipher during the Boer War and World War I. Unlike simple letter-for-letter substitution, it resists casual frequency analysis: a pair like "TH" doesn't always encrypt to the same ciphertext pair the way a single letter would.

How it works

  1. Build a 5x5 grid from a keyword. Duplicate letters are dropped, and the remaining cells are filled with the rest of the alphabet in order. Since the grid only has 25 cells, one letter has to give way — the standard convention merges I and J into a single cell (this tool also offers an Omit Q variant, which drops Q and keeps I and J separate).
  2. Split the message into digraphs (letter pairs). If a pair would repeat the same letter (like the "LL" in "BALLOON"), a filler letter is inserted between them. An odd-length message gets a filler appended to the end.
  3. Encrypt each pair:
    • Same row → shift each letter one cell right (wrapping to the start of the row).
    • Same column → shift each letter one cell down (wrapping to the top).
    • Otherwise (a rectangle) → swap each letter into its own row but the other letter's column.
  4. Decrypting reverses the row/column shifts (left instead of right, up instead of down); the rectangle rule is its own inverse, so it stays the same.

How to use this tool

  1. Choose Encode or Decode.
  2. Enter your Keyword — this sets the layout of the 5x5 grid, so decoding a message requires the same keyword used to encode it.
  3. Type or paste your Input Text.
  4. Optionally change the Matrix Variant (I/J merged vs. Omit Q) and the Filler Letter — both must match what was used to encode the message.

The result updates automatically. Non-letter characters (numbers, punctuation, spaces) are stripped before encoding, and inserted filler letters remain in decoded output — Playfair was never designed to reverse perfectly back to the original spacing and punctuation, only to the original letters.

A worked example

With the keyword PLAYFAIR EXAMPLE, the plaintext "Hide the gold in the tree stump" encrypts to BM OD ZB XD NA BE KU DM UI XM MO UV IF — a well-known textbook example this tool reproduces exactly.

Is the Playfair cipher secure?

No. While stronger than a monoalphabetic substitution cipher, Playfair is still vulnerable to digraph frequency analysis given enough ciphertext, and automated solvers crack it in seconds. Use it for puzzles, historical re-creations, escape rooms, and learning classical cryptography — never for protecting real secrets. For actual encryption, use a modern algorithm such as AES.

Privacy

This tool runs entirely in your browser. Your text and keyword are never uploaded to a server.

cipherencodingcryptographydigraphplayfair

Love the tools? Lose the ads.

One payment clears every ad from your account, for good. No subscription, no tracking.