Playfair Cipher

Characters—
Letter pairs—

How Playfair Cipher is calculated: Pairs of letters are encrypted through a 5 by 5 key square: letters in the same row shift right, letters in the same column shift down, and letters in a rectangle swap corners. I and J share one cell.

A Playfair Cipher, in plain words

The Playfair cipher encrypts letters in pairs through a 5 by 5 key square, so the same letter can become different letters depending on its partner. It was the first practical digraph cipher, and the British used it in the field in both world wars. It works entirely in your browser: you type or paste text, and the result appears at once, with nothing uploaded and nothing stored. People searching for a playfair cipher usually want exactly that — a quick answer without an account, a download, or a wait.

History readers working through wartime ciphers, puzzle fans who want a step up from single-letter ciphers, and students learning why encrypting pairs hides single-letter frequencies. Students use it for homework and puzzles, developers use it at work, and writers use it when a deadline is close. The common thread is simple: the job is small, the answer should be instant, and the text should stay private.

This page keeps that promise. The playfair Cipher runs on your own device, so your words never leave the tab. You can use it as often as you like, on any text, and close the page knowing nothing was saved anywhere — there is no history, no log, and no sign-up standing between you and the answer.

If you have never used a tool like this before, start with the example on this page and change one thing at a time — one word, one setting — and watch the result change. That is the fastest way to learn what each input does, and it works for every tool in this family, because they all follow the same pattern: text in, result out, nothing saved.

How the Playfair Cipher does its job

The keyword fills a 5 by 5 square first — MONARCHY gives M, O, N, A, R, C, H, Y, then the rest of the alphabet, with I and J sharing a cell. The message is split into pairs, and each pair is encrypted by its position: same row shifts right, same column shifts down, and a rectangle swaps corners. A doubled letter is split with an X, and an odd-length message gets a trailing X. The rule this page uses is: Pairs of letters are encrypted through a 5 by 5 key square: letters in the same row shift right, letters in the same column shift down, and letters in a rectangle swap corners. I and J share one cell.

Playfair hides single-letter frequencies, which is why it resisted codebreakers for decades, but pairs of letters still show patterns — the most common English pair, TH, leaves a trace — and a long message falls to digraph frequency analysis. It also cannot tell I from J, and the X padding sometimes has to be guessed away when reading the decrypted text.

Because the rule never changes, the same input always gives the same output. Run the example below twice and the result will match exactly, character for character. That predictability is what makes the tool useful for checking your own work. For a different kind of text job, the text reverser covers the next step once you have your result. The comparison section further down this page explains which of the two fits which job, so you can pick before you paste.

The rule above is the whole method — there is no hidden step and no second pass. What you see in the rule is what the tool computes, which is why the worked example below can be followed by hand, one step at a time, with a pencil if you like.

The keyword and the key square, explained

The keyword builds the 5 by 5 square. Its letters go in first, in order, with repeats dropped, and then the rest of the alphabet follows — I and J share a single cell, so J is always read as I. A keyword with many distinct letters, like MONARCHY, makes a square that looks nothing like the plain alphabet.

With the keyword MONARCHY, the classic example 'instruments' becomes 'GATLMZCLRQXA'. The pairs are IN, ST, RU, ME, NT, SX — the last pair is SX because the message ends with an odd letter and the tool pads it with an X. The final pair, SX, is a same-column pair, so both letters shift down.

If you are setting a puzzle, use a keyword with 7 or 8 distinct letters — MONARCHY has 8 — so the square is well mixed. Short keywords like KEY leave most of the square in plain alphabetical order, which is easy to spot.

When in doubt, try the worked example below first — it uses the page defaults, so it shows the tool working exactly as it ships.

Paste from anywhere — a document, a chat, a web page. The tool reads only the text you give it, so stray formatting, links, and images are left behind. If the pasted text looks odd, paste it as plain text first and then copy it in, so nothing invisible rides along.

A worked example

Take this input: the classic textbook message 'instruments' with the keyword 'MONARCHY'. The message is split into pairs: IN, ST, RU, ME, NT, SX. Each pair is encrypted by its place in the square — IN becomes GA, ST becomes TL, RU becomes MZ, ME becomes CL, NT becomes RQ, and SX becomes XA. The result is 'GATLMZCLRQXA' — 12 characters, 6 letter pairs.

Decrypt 'GATLMZCLRQXA' with the same keyword and you get 'INSTRUMENTSX' back. The trailing X is the padding the tool added to the odd-length message — drop it when you read the result.

Try 'HELLO' with the keyword 'PLAYFAIR': the double L is split with an X, so the pairs are HE, LX, LO, and the result is 'KGYVRV'. That X in the middle is the tool's doing, not part of your message.

You can check the result yourself without trusting the page. Reverse the operation — decrypt what you encrypted, or run the output back through the tool with the opposite setting — and the original input should come back. If it does not, the first thing to check is the input: a missing letter, an extra space, or a setting that changed between the two runs.

Who uses a Playfair Cipher — and why

A history student re-creates the cipher the British used in the Boer War and the First World War, encrypting the same messages to see how it worked in the field. It is the kind of job that comes up often enough to remember, and rarely enough to justify installing anything for.

A puzzle hunt uses Playfair as the final stage, after solvers have already cracked a Caesar shift and a rail fence, because pairs are the next step up in difficulty. The case converter is the natural next stop when the result needs a different treatment. It answers the question this page leaves open, so the two together cover the whole job.

A teacher shows why letter frequency fails against Playfair — the most common letter, E, encrypts differently every time, depending on its partner.

Playfair Cipher vs ROT13 Encoder

The ROT13 encoder shifts single letters by a fixed 13, while Playfair encrypts letter pairs through a key square. ROT13 is a single-letter shift; Playfair is a digraph cipher with a real wartime history. The ROT13 encoder is the closest comparison on this site, and the two answer different questions. Both are free, both run in your browser, and neither asks for an account.

Pick the playfair Cipher when you want a digraph cipher with a real wartime history, where pairs of letters are the unit of encryption. Pick the rot13 encoder when you want the simplest fixed shift, with no key to share or remember.

In practice most people keep both bookmarked. They are small, free, and private, and switching between them costs nothing — paste the same text into each and compare the outputs side by side before deciding which one fits the job in front of you. The habit that saves the most time is deciding the job first and the tool second: once you know whether you need a cipher, a conversion, or a count, the choice between two similar tools is usually obvious.

Where people go wrong with a Playfair Cipher

Forgetting that I and J share a cell. A message with J is encrypted as if it were I, and the decrypted text will show I where the original had J — that is not an error, it is the rule.

Reading the padding X as part of the message. The tool adds X to split doubled letters and to pad an odd length, so a decrypted message may carry X letters that were never in the original.

Using a short keyword. With a keyword like KEY, most of the square stays in alphabetical order and a codebreaker can guess the square quickly. Encrypting a message with an odd number of letters and expecting the same length back. Playfair works in pairs, so an odd-length message always gains a trailing X. The fix in every case is the same: check the input, check the setting, and test with the worked example before trusting a long result.

If the result still looks wrong after checking the input, run the worked example exactly as written. If the example works and your input does not, the difference is in your input — compare them character by character, including spaces, until the odd one out shows itself.

How to use this Playfair Cipher

Type your message, type a keyword, and choose Encrypt or Decrypt. The result appears live as you type, and switching direction with the same keyword turns ciphertext back into the original message. The word counter can help with the next step once you have your output.

Work the first pair by hand before trusting a long message — with MONARCHY, IN should give GA, and if it does, the square is right. Keep the keyword with the message, or the reader cannot decode it.

The result can be copied with the buttons above it, or shared and printed from the actions on the page. If you use the tool often, bookmark the page — the address never changes, and your last input is not saved, so a fresh visit always starts clean. That also means there is nothing to clear and nothing to log out of when you are done.

Everything on this page is free, with no account and no limit on how often you use it. Your text is processed in your browser and never sent to a server, so drafts, names, and private notes stay on your device. If the result looks wrong, check the input first — a stray space or a missing character is the cause far more often than the tool itself.

Frequently Asked Questions

The square holds 25 cells and the alphabet has 26 letters, so one pair must share. Playfair merges I and J, and every J is read as I. The decrypted text shows I where the original had J.

The tool adds X in two places: between a doubled letter, so LL becomes LX LO, and at the end of an odd-length message. Those Xs are padding, not part of your message.

The textbook example uses the keyword MONARCHY on the message 'instruments', which encrypts to 'GATLMZCLRQXA'. It appears in many cryptography books with exactly that keyword and message.

Not by modern standards. It hid single-letter frequencies well enough for field use in the early 1900s, but digraph frequencies leak through, and a computer breaks it quickly today. It is a teaching and puzzle cipher.

More free tools

More calculators and utilities from Sortrun — free, no sign-up.