Skip to content

Home / Puzzles, Locks & Codes

Pigpen Cipher: How It Works and How to Use It in a Puzzle

November 19, 2026 · 6 min read

Two grids, two X shapes and a handful of dots turn the alphabet into 26 angular symbols. Here is the key, every symbol described in words, and how to build a fair puzzle with it.

Pigpen Cipher: How It Works and How to Use It in a Puzzle
Photo: Andrys / Pixabay

The pigpen cipher swaps each letter for the piece of a grid that the letter sits in. Draw two tic-tac-toe grids and two X shapes, write the alphabet into the spaces, and every letter gets its own small fence of lines, with or without a dot inside. The result looks cryptic and takes about a minute to learn, which is why it is a regular in escape rooms, treasure hunts and children's code books.

The pigpen cipher key

A commonly used key fills the shapes in alphabetical order. A to I go into the first grid. J to R go into a second grid that has a dot in every cell. S to V go into the four spaces of an X, and W to Z into a second X with dots.

RowFirst grid: no dotsSecond grid: a dot in every cell
TopA | B | CJ | K | L
MiddleD | E | FM | N | O
BottomG | H | IP | Q | R

Each X has four spaces: one at the top, one on the left, one on the right and one at the bottom.

Space in the XFirst X: no dotsSecond X: a dot in every space
TopSW
LeftTX
RightUY
BottomVZ

A letter's symbol is simply the lines that touch its space. A sits in the top left corner of a grid, where only two lines border it, one on its right and one underneath, so A is drawn as those two lines. E sits in the middle with a line on every side, so E is a closed square. Letters from the dotted shapes are drawn the same way with a dot added: N, the middle of the second grid, is a square with a dot in it.

Every symbol in words

Thirteen positions, each used twice, give all 26 symbols. Half of them carry a dot.

Where the letter sitsLines you drawWithout a dotWith a dot
Top left of a gridright side and bottom: a backwards LAJ
Top middleleft, bottom and right: a box open at the topBK
Top rightleft side and bottom: an LCL
Middle lefttop, right and bottom: a box open on the leftDM
Centerall four sides: a closed squareEN
Middle righttop, left and bottom: a box open on the rightFO
Bottom lefttop and right side: like a 7GP
Bottom middleleft, top and right: a box open at the bottomHQ
Bottom righttop and left side: a mirrored 7IR
Top of an Xa VSW
Left of an Xa > signTX
Right of an Xa < signUY
Bottom of an Xan upside-down VVZ

How to write and decode a message

To write:

  1. Draw the key on scrap paper first. It is quicker than remembering it.
  2. Take the message one letter at a time. Find the letter, copy the lines around it and add the dot if its shape has dots.
  3. Leave a clear gap between words, or run the words together if you want the puzzle to be harder.

The word KEY comes out as three symbols. K is a box open at the top with a dot. E is a closed square with no dot. Y is a < sign with a dot.

Decoding runs the other way. Look at the shape to find the position, then look for a dot to choose between the two letters that share it. An angular shape with square corners belongs to a grid; a pointed one belongs to an X.

Try these four symbols: an L with a dot, a backwards L, a box open on the left with a dot, and a 7 with a dot. The first is the top right of the dotted grid, which is L. The backwards L without a dot is A. The box open on the left with a dot is M, and the dotted 7 is P. The word is LAMP.

Variants: check which key you have

There is no single official pigpen alphabet, and a message written with one key turns into nonsense when read with another.

  • The order of the shapes changes. The key above goes grid, grid, X, X. Another common one goes grid, X, grid, X, which puts J to M in the first X and N to V in the dotted grid.
  • The X is filled in different ways. Our key places the letters top, left, right, bottom. A worksheet from National Museums Scotland fills it going round the X, with U at the bottom and V on the right, and likewise Y at the bottom and Z on the right. If a decoded word is one letter off, U, V, Y and Z are the first letters to doubt.
  • Some versions use three grids and no X: no dot, one dot and two dots.
  • Harder versions write the alphabet into the shapes backwards, down the columns or in a scrambled order.

None of the usual keys has symbols for numbers, so write numbers out as words.

Where the cipher comes from

Nobody knows who invented it, and accounts of its early history disagree. It is best known as the Freemasons' cipher: a worksheet from the U.S. National Institute of Standards and Technology says that Freemasons of the 18th century used it so that their records stayed private, and National Museums Scotland notes that it can be seen on the tombstones of some Freemasons. Wikipedia's article on the cipher adds that a gravestone in Trinity Church's cemetery in New York City carries a line of these symbols that deciphers to "Remember death". The cipher's other names include Masonic cipher, tic-tac-toe cipher, Napoleon cipher and Rosicrucian cipher.

Cracking it without the key

Pigpen is a simple substitution cipher: every letter always becomes the same symbol. That makes it weak as a secret and friendly as a puzzle. A solver with no key treats it like any cryptogram: count which symbol appears most often and try E, the most common letter in English; test A and I for a symbol that stands alone as a word; look at doubled symbols.

Pigpen also gives away something a letter cryptogram does not. The shape of a symbol tells you where its letter sits, and neighbors in the alphabet are neighbors in the grid. Once you are sure of one or two letters you can pencil in the rest of that grid and see if the message starts to read.

Using pigpen in an escape room or a hunt

  • Keep the message short: one word or a short phrase. Copying symbols is slow, and a long message turns a puzzle into clerical work.
  • Draw large and neat, with every dot clearly inside its shape. Sloppy symbols are what make a pigpen puzzle unfair.
  • Decide how the players get the key. Hand it over, hide it, split it (grids on one card, X shapes on another), or give the empty shapes and let the team work out that the alphabet goes in order.
  • Whatever you choose, the key the players find must be the one you wrote with, including how the X is filled.
  • For a second layer, write the symbols in invisible ink, so the team has to reveal the message before decoding it.
  • Test it on someone who has only what the players will have.

Pigpen is one of several symbol and letter codes that designers use; the rest are in our guide to escape room puzzles.

Questions

What is the pigpen cipher also called?

It is known as the Masonic cipher or Freemason's cipher, and also as the tic-tac-toe cipher, the Napoleon cipher and the Rosicrucian cipher. All the names refer to the same idea of drawing the part of a grid around each letter.

How do you decode a pigpen cipher without the key?

Start by assuming the common alphabetical key and see if words appear. If they do not, solve it as a substitution puzzle: the most frequent symbol is probably E, and the positions of the symbols in the grid help you place the neighboring letters.

Is the pigpen cipher secure?

No. It hides a message from a casual glance and nothing more, because the key is widely known and each letter always maps to one symbol. It is a puzzle cipher, not a way to protect real secrets.

Why is it called the pigpen cipher?

The explanation given by the code reference site dCode is that the symbols look like pens and the dots like small pigs inside them.

Sources

  1. Wikipedia, Pigpen cipher
  2. NIST, The Pigpen Cipher (Cybersecurity Career Awareness Week worksheet)
  3. National Museums Scotland, Cryptography Challenge
  4. dCode, Pigpen Cipher

Next clue