Skip to content

↑↓ navigate ↵ open Esc close Search runs locally

Polybius Square Cipher Encoder & Decoder

Turn each letter into its row and column in a 5×5 grid, and coordinates back into letters. Use the standard square or build one from a keyword, shown live as you type.

  • Runs in your browser
  • Nothing is uploaded
  • Free, no sign-up
0 chars
Polybius
Runs in your browser. Nothing is uploaded. Tip: run it twice to get the original back

How to use the Polybius square tool#

  1. Choose Encode or Decode.
  2. Leave Key empty for the standard alphabet square, or type a keyword to build a mixed square. The Square under the tool shows the grid.
  3. Type or paste. Each letter becomes two digits: its row, then its column. J is treated as I.
  4. Pick a Format with or without spaces between the pairs, then copy the result.

Examples#

Encode with the standard square

Input
Hello
Output
23 15 31 31 34

H is in row 2, column 3, so it becomes 23.

Decode coordinates

Input
44 23 11 33 25 43
Output
THANKS

44 = row 4, column 4 = T.

Use a keyword square

Input
Hello
Output
24 12 32 32 35

The keyword moves D, E and V to the front of the square, so every coordinate changes.

What is the Polybius square?#

The Polybius square places the alphabet in a 5×5 grid and replaces each letter with two numbers: its row and its column. It is named after the Greek historian Polybius, who described a similar grid around 150 BC for signalling with torches: one set of torches for the row, another for the column. Because the alphabet has 26 letters and the grid has 25 cells, I and J usually share a cell.

The standard square#

plaintext
    1 2 3 4 51   A B C D E2   F G H I K3   L M N O P4   Q R S T U5   V W X Y Z

Read the row first, then the column: H is in row 2, column 3, so it becomes 23. HELLO becomes 23 15 31 31 34.

Keyword squares#

To make the square less predictable, write a keyword first (skipping repeated letters) and then the rest of the alphabet, just like the Playfair cipher does. With the key DEV, the first row becomes D E V A B, and every coordinate changes.

Where the Polybius square appears#

  • Tap code: prisoners of war tapped the row and column on walls, using a 5×5 grid with K merged into C.
  • Stronger ciphers: the ADFGVX cipher of the First World War and the bifid cipher both start with a Polybius square.
  • Puzzles: digits 1–5 in pairs are a classic hint in puzzle hunts and escape rooms.

The Polybius square is not secure on its own. Each letter always gets the same pair of digits, so frequency analysis breaks it like any simple substitution cipher.

Polybius square in code#

javascript
const SQUARE = 'ABCDEFGHIKLMNOPQRSTUVWXYZ'; // no J const encode = (text) =>  [...text.toUpperCase().replace(/J/g, 'I').replace(/[^A-Z]/g, '')]    .map((c) => { const i = SQUARE.indexOf(c); return `${Math.floor(i / 5) + 1}${(i % 5) + 1}`; })    .join(' '); encode('Hello'); // "23 15 31 31 34"

Common errors and fixes#

  • Decoding gives the wrong letters

    The message may use a keyword square, or read column first instead of row first. Try swapping the two digits of a pair, or ask for the keyword.

  • Some pairs decode as ?

    Each digit must be between 1 and 5. A 0, 6 or higher digit means a typo, or a different grid size such as 6×6 (which adds the digits 0–9).

  • The decoded text has I where J was

    I and J share a cell in a 5×5 square, so J always decodes as I. Read it from context.

Frequently asked questions#

How do I decode a Polybius square?

Choose Decode and paste the digit pairs. The first digit is the row and the second the column of the letter in the grid.

Why are I and J in the same cell?

A 5×5 square has 25 cells for 26 letters, so two letters must share. I and J is the usual choice because they look and sound alike.

What is the difference between the Polybius square and tap code?

Tap code is a Polybius square sent by tapping: first the row, then the column. Tap code merges K into C instead of J into I.

Is my text uploaded?

No. Everything runs in your browser.

Your next tool is one search away.

Free, private developer tools that run in your browser. No signup, nothing uploaded, no waiting.

Browse all tools

Tip: press Ctrl D to bookmark dev247.