✖

Pigpen cipher: key and translator

The pigpen cipher replaces each letter with the shape of the cell it lies in, in a grid drawn according to the key (the picture below). For example, E sits in the middle of a noughts-and-crosses grid, #, with lines all around it, so it becomes a square. The name comes from the “pigpen”, a small enclosure for pigs, because every letter has its own little pen. It is also known as the Masonic cipher or the Freemasons’ cipher. A message then looks like a row of strange marks, but you can draw the key from memory in a minute: two grids and two crosses.

Text to pigpen cipher converter

Type a message and the converter turns it into pictures. It drops accents (č is written as c) and leaves out digits and punctuation.

The default text, “Poklad je pod dubem”, is Czech for “the treasure is under the oak”.

It does not convert in the opposite direction, but the key below is all you need to decipher a message.

The pigpen key

Two # grids with the letters A to I and J to R, where in the second grid every letter has a dot. Below them two X-shaped crosses with the letters S, T, U, V and W, X, Y, Z, where in the second cross the letters have dots Two # grids with the letters A to I and J to R, where in the second grid every letter has a dot. Below them two X-shaped crosses with the letters S, T, U, V and W, X, Y, Z, where in the second cross the letters have dots

The procedure is simple:

  1. Draw a # grid, like a noughts-and-crosses board, and write A to I in its cells, row by row.
  2. Next to it draw a second grid, write J to R in it and add a dot to every letter.
  3. Below them draw an X and write S at the top, T on the left, U on the right and V at the bottom of its four wedges (the triangles into which the lines divide it).
  4. Next to it draw a second X with the letters W, X, Y, Z in the same order and with dots.

That makes 9 + 9 + 4 + 4 = 26 cells, one for each letter of the international alphabet (CH, which counts as a single letter in Czech, is written as C and H).

How to write and read the pigpen cipher

To write a letter, find its cell and trace the lines that surround it. The outer edge of a grid has no line, so the cells on the outside are open on that side. B is in the middle of the top row with a line on the left, on the right and below, so it looks like the letter U. O is in the second grid, on the right in the middle, with a line above, on the left and below, and also a dot.

The grid A to I with cell B highlighted in red and its shape on the right, below it the grid with dots and cell O highlighted in red, with its shape and dot The grid A to I with cell B highlighted in red and its shape on the right, below it the grid with dots and cell O highlighted in red, with its shape and dot

The X works in a similar way, except that instead of a cell we have a wedge, bounded by two slanting lines. S at the top is therefore written as ∨, T on the left as >, U on the right as < and V at the bottom as ∧. For W, X, Y and Z the dot goes inside the wedge.

Let’s try writing the whole word “tábor” (Czech for “camp”; we leave out the accent over the á). T is the wedge on the left, A is a corner made of the right and bottom lines, B is the U shape and O is a pen with a dot, open to the right. R is in the bottom right corner of the grid with dots, so it becomes a corner made of the left and top lines with a dot inside.

The letters T, A, B, O, R and below each of them its symbol in the pigpen cipher The letters T, A, B, O, R and below each of them its symbol in the pigpen cipher

To decipher, work backwards. Is the mark square (a grid) or slanting (an X)? Does it have a dot? Which cell looks exactly like this? A square shape without a dot, with a line on the left, on the right and below, is B, because only the middle cell of the top row is bounded exactly like that.

Variants of the pigpen cipher

There are several layouts of the letters. Some people draw a grid, a cross, a grid and a cross and fill in the letters in order, so that straight after A to I comes a cross with J to M and only then the grid with dots. Others put the dots elsewhere or replace them with dashes. That is why it is a good idea to show the key before a game.

An older variant, which according to Wikipedia the Rosicrucians used in the 17th century, gets by with a single grid. It writes three letters in each cell (ABC, DEF, GHI…) and dots show which of them is meant.

The best variant, though, is your own. If you write the letters into the grids and crosses in a scrambled order, say starting with a keyword as with the Polybius square, the code turns into a real cipher. Only someone who knows your key can then read the message.

How to break the pigpen cipher without the key

The marks look mysterious, but each letter always has one and the same mark. Mathematically it is therefore an ordinary substitution of letters, just like the Atbash cipher, except that pictures are written instead of other letters. If we named the 26 symbols with numbers, we would get the number cipher with a different table.

That is why even someone who has never seen the key can break it, as long as the message is long enough. Frequency analysis helps: the most common symbol in the text probably belongs to the most common letter of the language, in Czech for example O or E. The look of the marks does not matter, only how often they repeat.

Where the pigpen cipher comes from

Freemasons began to use it at the beginning of the 18th century and, according to Wikipedia, kept their records of history and ceremonies in it so that not just anyone could read them. Hence the name Masonic cipher. Similar grids are older, though: Cornelius Agrippa described them for Hebrew letters in the 16th century. A well-known example is the grave of James Leeson, who died in 1794 and lies in the churchyard of Trinity Church in New York. His headstone has the inscription “Remember death” carved in one of the variants of the pigpen cipher.

It is popular at camps mainly because of the key: children draw it on a piece of paper and write messages in chalk on a wall or with a stick in the sand.