T

Text Machine

Powerful text tools, in your browser

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.

Square settings

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.

Plain text
Coordinates

Enter text above to see the result here.

Polybius square

1

2

3

4

5

1

A
B
C
D
E

2

F
G
H
I/J
K

3

L
M
N
O
P

4

Q
R
S
T
U

5

V
W
X
Y
Z

How to use Polybius Square

  1. 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. 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. 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. 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. 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?
The Polybius square is a method of turning letters into numbers, described by the ancient Greek historian Polybius. The alphabet is arranged in a grid, and each letter is replaced by a pair of numbers giving the row and column of its cell. It was first used to send messages over distance with torches and later became a building block inside many stronger ciphers.
How does the Polybius square cipher work?
Each letter is found in the grid and replaced by its row number followed by its column number. In the standard 5×5 square, A is in row 1, column 1, so it becomes 11, and H is in row 2, column 3, so it becomes 23. To decode, you take the digits two at a time and read each pair as a row and column to find the letter.
Who invented the Polybius square?
It is named after Polybius, a Greek historian of the second century BC, who described it in his Histories. He proposed it as a way to signal letters across distance using two groups of torches — one for the row and one for the column — so it was originally a method of long-distance communication as much as a cipher.
What is the difference between the 5×5 and 6×6 squares?
The 5×5 square has 25 cells, so two letters — usually I and J — must share one cell to fit the 26-letter alphabet. The 6×6 square has 36 cells, enough for all 26 letters plus the digits 0 to 9 with nothing merged. Use the 5×5 square for classic puzzles, and the 6×6 square when you need numbers or want every letter to round-trip exactly.
Why do I and J share a cell?
A 5×5 grid has only 25 cells but the Latin alphabet has 26 letters, so one pair must be combined. By tradition I and J share a cell, because they were once treated as the same letter and are easy to tell apart from context. The side effect is that a J you encode will decode back as an I. The 6×6 grid avoids this by providing a separate cell for every letter.
What does the keyword do?
A keyword scrambles the grid. Its unique letters are written into the square first, in order and without repeats, and the rest of the alphabet follows. For example, the keyword POLYBIUS fills the 5×5 square as POLYBIUSACDEFGHKMNQRTVWXZ. This changes every coordinate, so both sender and receiver must use the same keyword and grid size. Leaving it blank gives the plain alphabetical square.
Can you show a worked Polybius example?
Using the plain 5×5 square, the word HELLO encodes to 23 15 31 31 34, because H is 23, E is 15, L is 31, the second L is 31 again, and O is 34. To decode, you split the digits into pairs and read each pair as a row and column, so 23 15 31 31 34 becomes HELLO.
How do you decode a Polybius cipher?
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 of the grid. In this tool, choose Decode, select the same grid size and keyword that encoded the message, and paste the coordinates. It ignores spaces, commas, and line breaks, so you can paste the numbers in almost any layout.
What is the Polybius square used for?
Beyond simple puzzles, the Polybius square is the foundation of several famous systems. Prisoners of war have used it as a tap code, tapping the row and then the column of each letter; it underlies the Russian Nihilist cipher; and it forms the core of the Bifid cipher and the First World War ADFGX and ADFGVX ciphers. Converting letters into coordinates is a step that many stronger ciphers build on.
How secure is the Polybius square cipher?
On its own, not secure. It is a fixed substitution that simply swaps each letter for two digits, so it is easy to break with letter-frequency analysis, and adding a keyword only slows that down a little. Its real value is as a building block for stronger ciphers and as a clear way to learn cryptography. For protecting real information, use a modern algorithm such as AES.
Does the Polybius square keep spaces and punctuation?
No. Encoding works on grid characters only — the letters, plus the digits in the 6×6 square — because spaces and punctuation have no cell, so they are skipped. This means a decoded message comes back as a continuous run of characters without the original spacing. It is a normal feature of the cipher rather than a limitation of the tool.
Is my text uploaded to a server?
No. All encoding and decoding happens entirely in your browser, so your text is never uploaded, logged, or stored. Even a share link keeps your text, grid, and keyword in the part of the URL after the hash, which browsers never send to a server, so your message stays private until you choose to share the link.

Related tools

Keep going with these handy tools

Bifid Cipher

Trifid Cipher

Nihilist Cipher

Bazeries Cipher

Caesar Cipher

Vigenère Cipher