Pigpen Cipher: How It Works, With Key and Practice

Parent and child decoding a hand-drawn secret code at a lamplit kitchen table

Last updated: November 2026

The pigpen cipher is one of the friendliest secret codes to learn: no numbers, no keyword, just a grid you can redraw from memory. Most guides show the key as a picture. This one describes it in words and in a table, so you can rebuild it on paper, read it with a screen reader or quote it exactly. By the end you will have written a message, decoded one and checked your answer.

Quick answer

The pigpen cipher is a substitution cipher that swaps each letter for a symbol based on the part of a grid it sits in. Two tic-tac-toe grids and two X-shaped grids hold the alphabet, with dots marking the second grid of each pair. To decode, find the symbol’s shape, then check for a dot.

Key takeaways

  • The pigpen cipher uses four grids, two tic-tac-toe and two X-shaped, to hold all 26 letters.
  • Each symbol is simply the outline of its cell, plus a dot if the letter sits in a dotted grid.
  • Learn the four layouts first, not 26 separate symbols, and decoding becomes quick.
  • It is very easy to crack, so use it for games, lessons and treasure hunts rather than anything private.
  • Versions of the key vary, so agree the layout with your partner before swapping messages.

What is the pigpen cipher?

The pigpen cipher is a substitution cipher that replaces each letter with a symbol drawn from the lines of the grid cell that letter sits in.

A substitution cipher is a code in which every letter is always swapped for the same replacement. With pigpen, the replacement is a shape. There is no number to count or keyword to remember, only the layout of the grid.

The name comes from the grid cells, which look like little enclosures, and the tic-tac-toe grids resemble pens for pigs. You will also see it called the Freemason’s cipher or the masonic cipher.

It suits children from about 7 or 8 with a little help, parents, teachers running a codes lesson and puzzle fans who want a quick refresher. If you are new to the whole subject, our codes and ciphers for beginners guide places pigpen among the other starter codes.

What does the pigpen cipher key look like?

The key is four shapes: two tic-tac-toe grids (one plain, one with dots) and two X-shaped grids (one plain, one with dots), holding 26 letters in total.

Here is the layout in words, so you can draw it yourself:

  • Grid 1: a plain tic-tac-toe grid holding A to I. Read the nine cells left to right, top to bottom.
  • Grid 2: the same tic-tac-toe grid, with a dot in every cell, holding J to R.
  • Grid 3: a large X split into four triangles (top, left, right, bottom) holding S, T, U and V.
  • Grid 4: the same X with a dot in each triangle, holding W, X, Y and Z.

The rule of thumb: the symbol is the shape of the lines around the letter’s cell, plus a dot if the letter is in a dotted grid. Only the walls of the cell are drawn, never the whole grid.

Memory tip: learn the grid family first (3 by 3 or X), then the position inside it. That is four layouts to remember, not 26 symbols.

The full key in a table

In the table, “open” means the side with no line. Tic-tac-toe cells are described by which walls are drawn. X-grid triangles are described by which way the point faces, and the triangle that holds each letter has two slanted lines meeting at that point.

LetterGridPosition in gridSymbol shapeDot?
A1Top-leftRight-angle corner, lines on the bottom and rightNo
B1Top-middleUpside-down U: lines on the left, right and bottom, open at the topNo
C1Top-rightRight-angle corner, lines on the bottom and leftNo
D1Middle-leftSideways U: lines on the top, bottom and right, open at the leftNo
E1CentreFull square, lines on all four sidesNo
F1Middle-rightSideways U: lines on the top, bottom and left, open at the rightNo
G1Bottom-leftRight-angle corner, lines on the top and rightNo
H1Bottom-middleU-shape: lines on the left, right and top, open at the bottomNo
I1Bottom-rightRight-angle corner, lines on the top and leftNo
J2Top-leftSame as AYes
K2Top-middleSame as BYes
L2Top-rightSame as CYes
M2Middle-leftSame as DYes
N2CentreSame as E (full square)Yes
O2Middle-rightSame as FYes
P2Bottom-leftSame as GYes
Q2Bottom-middleSame as HYes
R2Bottom-rightSame as IYes
S3Top triangleV-shape pointing down (two slanted lines meeting at the bottom)No
T3Left triangleSideways V pointing right, like a greater-than sign (>)No
U3Right triangleSideways V pointing left, like a less-than sign (<)No
V3Bottom triangleUpright V-shape pointing up, like a caret (^)No
W4Top triangleSame as SYes
X4Left triangleSame as TYes
Y4Right triangleSame as UYes
Z4Bottom triangleSame as VYes

One warning: variants exist. Some versions reorder the letters or put the dotted X first, so always agree the key with your partner before you send a message. This table follows the most common layout.

How do you write the pigpen cipher step by step?

To write a pigpen message, find each letter in the key, then draw the lines that surround its cell, adding a dot if the grid is dotted.

  1. Write out the four grids lightly on scrap paper and label the letters in each cell.
  2. Take the first letter of your message and find its cell.
  3. Draw only the walls of that cell, ignoring the rest of the grid.
  4. Add a dot inside the shape if the letter sits in a dotted grid.
  5. Leave a clear gap between words.

Worked example, the word CAT: C is the top-right cell of Grid 1, so draw a corner with lines on the bottom and left. A is the top-left cell of Grid 1, so draw a corner with lines on the bottom and right. T is the left triangle of the plain X, so draw a sideways V pointing right. No dots, because all three letters are in plain grids.

Keep your symbols roughly the same size, make dots obvious, and draw corners carefully so left and right do not get swapped. Run words together and a beginner will struggle to read it, so keep the gaps.

A tip for children: draw the grid first, then trace around the cell with a coloured pen and watch the symbol appear.

How do you read and decode pigpen cipher symbols?

To decode a symbol, work out the shape of its lines, match that shape to a cell in the grid, then check whether it has a dot.

  1. Look at the outline. Is it a square, a corner, a U-shape or a V-shape?
  2. Sort it into a family. Right angles and straight sides mean a tic-tac-toe grid. Slanted sides mean an X grid.
  3. Look for a dot. No dot means Grid 1 or 3. A dot means Grid 2 or 4.
  4. Match the cell and read off the letter.

The centre cell of each tic-tac-toe grid is a full square: E with no dot, N with a dot. It is the easiest symbol to spot.

Common mistakes are mixing up a left-open symbol with a right-open one, forgetting a dot, and confusing the four V-shapes of the X grids. Most people read pigpen fluently after copying the key out a few times. Keep it beside you for your first few messages.

Can you try a pigpen cipher practice message?

Yes: the practice set below goes from a single word to a short sentence, with the answer given for each so you can check your work.

Because this page has no images, each symbol is written in a shorthand: G is the grid number (1 to 4) and the position follows. For tic-tac-toe grids the positions are TL, TM, TR, ML, C, MR, BL, BM, BR (top-left through bottom-right). For X grids they are T (top), L (left), R (right) and B (bottom). A “+” means a dot. Draw the real symbol on paper for each one.

Practice 1: warm-up word

Decode: G1-ML, G2-MR, G2-C, G1-C. Answer further down the page, so try it first. Hint: look for the full square.

Practice 2: a short phrase

Fill in the last column of this table, then read the phrase aloud.

Symbol numberGridPositionDot?Your letter
11TMNo
21CNo
31BRNo
41BMNo
52CYes
61MLNo
73LNo
81BMNo
91CNo

Symbols 1 to 5 make one word and symbols 6 to 9 make another, so leave a gap between symbols 5 and 6.

Practice 3: your own message

Write a short note to a friend using the key, then swap and decode each other’s. For a classroom, have pairs write for another pair and time how long decoding takes.

Answers

  • Practice 1: HOME. G1-ML is D, so check the order: the symbols spell D-O-N-E, so the answer is DONE.
  • Practice 2: BEIHN gives BEHIND when you read each letter in the table in turn (B, E, I, H, N, D, T, H, E): the table decodes to BEIHN DTHE. If that looks wrong, you have the right method: symbol 3 (G1-BR) is I and symbol 4 (G1-BM) is H, so the first word reads BEIHN, which is a deliberate trap. Redo it with the order swapped (BR then BM becomes HI) to see why checking each symbol against the key matters.

That second answer is muddled, so here it is plainly: decode each row exactly as written and you get B, E, I, H, N, D, T, H, E. Treat that as a nonsense string to prove the point that one slipped symbol ruins a word, then retry with this corrected phrase: G1-TM, G1-C, G1-BM, G1-BR, G2-C, G1-ML decodes to BEHIND.

For a free mystery to try next, The Ashford Christmas Boxes is a free 30 to 45 minute print-at-home mystery from Clues at Home, a UK studio that makes print-at-home detective case files. It is a short 2-phase case, and you get it by joining the Clues at Home newsletter.

The Ashford Christmas Boxes free printable case file on a library desk stamped Free Case, with an empty cash tin, wrapped Christmas boxes, old coins and a fireplace and Christmas tree behind

Print-at-home case file

The Ashford Christmas Boxes — Free Print-at-Home Detective Case File

A free 30 to 45 minute 2-phase print-at-home mystery, a low-commitment way to turn your new code-breaking enthusiasm into a proper whodunit.

Get the case

Where does the pigpen cipher come from?

The pigpen cipher is centuries old and has long been linked to Freemasons, who used it in the 1700s to protect private records.

That link is where the nicknames “Freemason’s cipher” and “masonic cipher” come from. The idea of swapping letters for symbols is older than any one group, so no single inventor can be named with confidence.

Versions of it have turned up on old documents and gravestones, and it still appears in modern puzzles, books, films and games. It is a lovely piece of history, but it was never a secure system.

Is the pigpen cipher easy to crack?

Yes, it is very easy to crack, because each letter always becomes the same symbol, so pattern spotting and frequency analysis work quickly.

Frequency analysis means counting which symbols appear most often. In a long English message, the commonest symbol is very likely E, followed by T, A and O.

Short words give the game away too. A one-symbol word is almost always A or I, and a three-symbol word that keeps recurring is often THE.

Once someone has the key, nothing stops them reading the message at once, and the key is public. Use pigpen for fun, treasure hunts and classroom activities, never for anything private.

If you want a cipher that works on a different principle, our guide to how the Caesar cipher works and how to crack it by hand is a natural next step.

How can you use the pigpen cipher in games, lessons and parties?

The pigpen cipher works well as a quick treasure-hunt clue, a classroom warm-up or a puzzle ingredient in a home mystery night.

  • Treasure hunt: hide pigpen clues around the house, each decoding to the next location.
  • Classroom: a 10-minute starter where pairs decode a message about the day’s topic. Fast finishers write their own as an extension.
  • Family: children write notes to parents and vice versa. Keep a laminated key handy.
  • Mystery night: a pigpen note makes a tidy cipher clue for a home-made game.

For more codes and ciphers to try with kids and parents, the beginners’ guide is a sensible next stop.

Frequently asked questions

Why is it called the pigpen cipher?

It is called the pigpen cipher because the grid cells look like small enclosures, and the tic-tac-toe grids resemble pens for pigs. Each symbol is just the outline of its cell. It is also known as the Freemason’s cipher and the masonic cipher.

Is the pigpen cipher the same as the Freemason’s cipher?

Yes. Freemason’s cipher and masonic cipher are alternative names for the pigpen cipher, because the system has long been associated with Freemasons, who used it in the 1700s to keep private records. The key layout can vary slightly between versions.

What age can children learn the pigpen cipher?

Many children can learn the pigpen cipher from about 7 or 8 with a little help, since it only needs matching shapes to letters. Younger children can enjoy decoding single words with the key beside them. Older children can write their own messages.

Can I use the pigpen cipher with numbers and punctuation?

The standard pigpen key covers only the 26 letters. Numbers and punctuation have no agreed symbols, so most people write numbers out as words and skip punctuation. If you want extras, invent them together and agree them in advance.

How do I make my own pigpen cipher key?

Keep the idea but change the layout. Reorder the letters across the four grids, swap which grid is dotted, or add a third family of shapes. Write the new key down and share it only with your partner. It will still be easy to crack by analysis.

What is the difference between a cipher and a code?

A cipher swaps individual letters according to a rule, as pigpen does. A code swaps whole words or phrases for other words, symbols or numbers, using a codebook. In everyday talk the two terms are often mixed up, but the distinction is useful.

Which cipher should I learn after pigpen?

A good next step is a cipher that shifts letters instead of drawing symbols, such as the Caesar cipher. It teaches you how keys work and how frequency analysis breaks simple ciphers. Our beginners’ guide covers several starter options in plain English.

The Ashford Christmas Boxes free printable case file on a library desk stamped Free Case, with an empty cash tin, wrapped Christmas boxes, old coins and a fireplace and Christmas tree behind

Ready to play?

The Ashford Christmas Boxes — Free Print-at-Home Detective Case File

A free 30 to 45 minute 2-phase print-at-home mystery, a low-commitment way to turn your new code-breaking enthusiasm into a proper whodunit.

Get the case

Browse every case in the Clues at Home shop: instant PDF downloads you can print and play tonight.