Polybius Square Cipher
Encode and decode the Polybius square cipher, replacing each letter with the row and column numbers of its cell in a lettered grid. Switch between the 5×5 and 6×6 squares, add an optional keyword to mix the grid, follow along on the live numbered square, and copy, download, or share the result. Everything runs in your browser.
Grid
Keyword
The classic 5×5 square holds 25 cells, so I and J share one cell, exactly as Polybius drew it. A decoded J therefore reads back as I. Rows and columns are numbered 1 to 5.
Enter text above to see the result here.
Polybius square
1
2
3
4
5
1
2
3
4
5
How to use Polybius Square
- 1
Choose encode or decode
Pick Encode to turn text into Polybius coordinate pairs, or Decode to turn pairs of digits back into letters.
- 2
Pick the grid
Choose the classic 5×5 square, where I and J share a cell, or the 6×6 square, which adds the digits 0 to 9 and keeps every letter separate.
- 3
Add a keyword (optional)
Leave the keyword blank for the plain alphabetical square, or enter a keyword to mix the grid. Both sides must use the same grid and keyword.
- 4
Type or paste your text
Enter your message and it is converted as you type. Encoding uses grid characters only, so spaces and punctuation are skipped.
- 5
Copy, download, or share
Copy the result, download it as a text file, or share a link that reopens the tool with your exact text, grid, and keyword ready to go.
Understanding the Polybius Square Cipher
What is the Polybius square cipher?
The Polybius square, also called the Polybius checkerboard, is a simple way of turning letters into numbers that was described by the ancient Greek historian Polybius more than two thousand years ago. The letters of the alphabet are written into a square grid, and each letter is then represented by a pair of numbers: the number of the row it sits in followed by the number of its column. The word HI, for example, becomes the two coordinate pairs for H and I.
Polybius did not invent it purely as a secret code. His original purpose was signalling across distance: by holding up torches in two groups — one group giving the row, the other the column — a message could be spelled out letter by letter over a line of sight. That made it one of the earliest ways to send arbitrary text over a long distance, an ancestor of the telegraph. As a cipher it is a substitution that replaces each letter with two digits, and it became a versatile building block inside many later, stronger ciphers.
How the Polybius square works
To encode, you find each letter in the grid and write down its row number and then its column number. Reading the coordinates the other way, row first and column second, is the universal convention. In the standard 5×5 square the letter A sits in row 1, column 1, so it becomes 11; the letter H sits in row 2, column 3, so it becomes 23. A whole message turns into a string of two-digit numbers, conventionally separated into pairs.
Because the grid is square, every letter maps to exactly two digits and every pair of digits maps back to one cell, which makes encoding and decoding completely mechanical. Spaces, punctuation, and anything without a cell are simply left out, so the output is a clean run of coordinate pairs. The tool above shows the live grid with its numbered rows and columns, so you can read any letter's coordinates straight off the square.
The 5×5 and 6×6 squares
The classic square is 5×5, which gives 25 cells — one short of the 26 letters of the Latin alphabet. The traditional fix is to let I and J share a single cell, since they are easy to tell apart from context when reading. In this version a message you encode with a J will come back as an I when you decode it, a small and well-known quirk of the cipher.
The tool also offers a 6×6 square of 36 cells, large enough to hold all 26 letters plus the ten digits 0 to 9 with nothing merged. This version keeps I and J separate and lets you encode numbers as well as letters, so text round-trips exactly. Choose the 5×5 square to match classic puzzles and historical examples, or the 6×6 square when you need every letter and digit to survive unchanged.
Mixing the square with a keyword
By default the grid is filled with the alphabet in order, but you can scramble it with a keyword. The unique letters of the keyword are written into the grid first, in order and without repeats, and the rest of the alphabet follows. A keyword of POLYBIUS, for instance, fills the 5×5 square as POLYBIUSACDEFGHKMNQRTVWXZ, so P lands in the top-left cell and becomes 11.
A keyword changes every coordinate, which means two people need to agree on both the grid size and the keyword to exchange messages. This is exactly how a keyed square is built for the Playfair cipher, and the live grid above highlights the keyword letters so you can see the mixing at a glance. Leaving the keyword blank gives the plain alphabetical square.
A worked Polybius example
Take the word HELLO and encode it with the plain 5×5 square. H is in row 2, column 3, giving 23; E is in row 1, column 5, giving 15; L is in row 3, column 1, giving 31; the second L is 31 again; and O is in row 3, column 4, giving 34. Strung together, HELLO becomes 23 15 31 31 34 — one coordinate pair per letter.
Reading it back is just as direct: split the digits into pairs and look each pair up in the grid as a row and column. Because the same letter always lands on the same cell, the two L's in HELLO produce the same pair 31 twice, a reminder that, like any simple substitution, Polybius text leaks the pattern of repeated letters.
Decoding a Polybius cipher
To decode, you reverse the process: take the digits two at a time, read the first as a row and the second as a column, and find the letter in that cell. Choose Decode above, pick the same grid size and keyword that were used to encode, and paste the coordinates. The tool is forgiving about format — it ignores spaces, commas, slashes, and line breaks, so you can paste the numbers laid out however you found them.
Only complete pairs are translated; a stray leftover digit at the end is ignored, and any pair that points outside the grid — a 0, or a 6 in a 5×5 square — is shown as a question mark so you can spot a transcription slip. If you are decoding with the 5×5 square, remember that an original J comes back as I, because those two letters shared a cell.
History and security of the Polybius square
Polybius described his square in the second century BC as a method for sending messages with torches, and the same five-by-five idea reappeared throughout history. Prisoners of war have used it as a tap code, knocking out the row and then the column of each letter on a wall or pipe; it underlies the nineteenth-century Russian Nihilist cipher; and it forms the heart of stronger systems such as the Bifid cipher and the First World War ADFGX and ADFGVX ciphers, which combine the square with transposition.
On its own the Polybius square offers no real security. It is a fixed substitution with no key unless you add a keyword, and even then the mapping is easy to recover from letter-frequency patterns. Its lasting value is as a tool that converts letters into coordinates — a step that other ciphers build on, and a clear, hands-on way to learn how classical cryptography works. For protecting real information today, use a modern algorithm such as AES; keep Polybius for puzzles, teaching, and capture-the-flag challenges.
Frequently asked questions
What is the Polybius square cipher?
How does the Polybius square cipher work?
Who invented the Polybius square?
What is the difference between the 5×5 and 6×6 squares?
Why do I and J share a cell?
What does the keyword do?
Can you show a worked Polybius example?
How do you decode a Polybius cipher?
What is the Polybius square used for?
How secure is the Polybius square cipher?
Does the Polybius square keep spaces and punctuation?
Is my text uploaded to a server?
Related tools
Keep going with these handy tools