# Pigpen cipher

The **pigpen cipher** is a geometric substitution cipher in which each letter of the alphabet is replaced by a symbol made of the grid lines that surround its assigned cell, so a message looks like a run of angular fragments rather than letters. It is also called the masonic cipher, Freemason's cipher, Napoleon cipher, and tic-tac-toe cipher.<sup>[1](https://masonicwiki.org/wiki/Pigpen_cipher)</sup>

| Key fact | Detail |
|---|---|
| Cipher type | Geometric simple substitution: letters are exchanged for symbols that are fragments of a grid<sup>[1](https://masonicwiki.org/wiki/Pigpen_cipher)</sup> |
| Symbol set | Geometric symbols derived from two grids and two X patterns, covering the 26 letters of the alphabet<sup>[2](https://ciphermuseum.com/ciphers/pigpen.html)</sup> |
| Earliest mention | Cited as early as 1531 by the German polymath Heinrich Cornelius Agrippa in *Three Books Concerning Occult Philosophy*<sup>[3](https://www.history.com/articles/ciphers-secret-codes-enigma-morse)</sup> |
| Masonic adoption | Became commonplace in the 18th century through use by Freemasons, which gave the system the name Freemason Cipher<sup>[3](https://www.history.com/articles/ciphers-secret-codes-enigma-morse)</sup> |
| Wartime use | Used by the British during the American War of Independence; a Hessian diary from the Revolution is partially written in pigpen, and the cipher remained in use through the American Civil War<sup>[3](https://www.history.com/articles/ciphers-secret-codes-enigma-morse)</sup><sup> • </sup><sup>[4](https://www.scientificamerican.com/podcast/episode/invisible-ink-and-other-science-of-10-04-20/)</sup> |
| Security | A monoalphabetic substitution, cryptographically equivalent to any fixed letter-to-symbol mapping and breakable by the same frequency analysis<sup>[2](https://ciphermuseum.com/ciphers/pigpen.html)</sup> |
| Modern role | Recreational and educational use in escape rooms, puzzle hunts, scouting, and school cryptography units<sup>[5](https://dotdashkey.com/reference/pigpen-cipher/)</sup> |

## How the cipher works

The standard key is built from four grids. The letters A through I fill a 3-by-3 tic-tac-toe board, J through R fill a second board, and the remaining letters S through Z are placed in two X-shaped grids. The symbol for a letter is simply the set of lines that enclose its cell: a letter in the top-left cell of a square grid is drawn as a right angle opening down and to the left, and a letter in the center of an X grid is drawn as the full X shape.<sup>[2](https://ciphermuseum.com/ciphers/pigpen.html)</sup><sup> • </sup><sup>[6](https://people.sc.fsu.edu/~jpeterson/cryptography.pdf)</sup>

Because two letters share each cell shape, a dot marks the second letter in a cell. In the common arrangement, A and E occupy the same corner position, so A is the bare angle and E is the same angle with a dot; a third letter assigned to a cell would carry two dots.<sup>[7](https://www.cerias.purdue.edu/education/k-12/teaching_resources/lessons_presentations/activitysheet01.pdf)</sup> The name comes from this visual logic: each letter sits inside the part of the "pigpen" that surrounds it.<sup>[7](https://www.cerias.purdue.edu/education/k-12/teaching_resources/lessons_presentations/activitysheet01.pdf)</sup>

The key is easy to recreate from memory because the grids are laid out logically, which is one reason the system spread so widely by hand.<sup>[8](https://publications.cedarville.edu/cedrus_press/invitation_to_cybersecurity/149/)</sup>

## History

The grid-substitution idea predates its fraternal associations. Pigpen-style ciphers were mentioned as early as 1531 by [Heinrich Cornelius Agrippa](https://www.edgepedia.org/heinrich-cornelius-agrippa), and one precursor, later called "The Kabbalah of the Nine Chambers," arranged the [Hebrew alphabet](https://www.edgepedia.org/hebrew-alphabet) rather than the [Latin alphabet](https://www.edgepedia.org/latin-alphabet) in grid chambers and served religious symbolism rather than any apparent cryptological purpose.<sup>[3](https://www.history.com/articles/ciphers-secret-codes-enigma-morse)</sup><sup> • </sup><sup>[1](https://masonicwiki.org/wiki/Pigpen_cipher)</sup>

**Freemason use.** Pigpen ciphers became commonplace in the 18th century when Freemasons adopted them, so much so that the system became known as the Freemason Cipher.<sup>[3](https://www.history.com/articles/ciphers-secret-codes-enigma-morse)</sup> According to one reference summary, English Freemasons had standardized a specific four-grid version by around 1737, using it informally in lodge correspondence, though the underlying grid concept almost certainly predates any single fraternal order's use of it.<sup>[5](https://dotdashkey.com/reference/pigpen-cipher/)</sup> Variations of the cipher were also used by the Rosicrucian brotherhood.<sup>[1](https://masonicwiki.org/wiki/Pigpen_cipher)</sup> Surviving evidence of the tradition is physical as well as documentary: Masonic tombstones incorporating text written in the cipher, dating from the late 1600s, have been found, one in New York City's Trinity Church Cemetery.<sup>[9](https://read-em-again.cdn.bibliopolis.com/images/upload/catalog-26-3-for-printing.pdf)</sup>

**Wartime and later use.** The cipher was not confined to lodges. Frary, quoted by HISTORY, reports that pigpen ciphers were used by the British during the American War of Independence.<sup>[3](https://www.history.com/articles/ciphers-secret-codes-enigma-morse)</sup> Scientific American's account of Revolutionary War spycraft notes that a Hessian diary from the period is partially written in a pigpen cipher and that the cipher was used up through the [American Civil War](https://www.edgepedia.org/american-civil-war).<sup>[4](https://www.scientificamerican.com/podcast/episode/invisible-ink-and-other-science-of-10-04-20/)</sup> A pigpen cipher table also appears within a mid-18th-century Masonic manuscript written in French held at the State Library in Moscow.<sup>[10](https://dspace.ut.ee/bitstreams/18c0caf0-518f-4329-ad7f-8c2ad121f0cc/download)</sup>

One distinction matters for anyone searching Masonic archives: the "cipher books" published for American Masonic ritual, with titles such as *Ecce Orienti* and *King Solomon and His Followers*, encode ritual text in a different way and are completely different from the pigpen cipher, even though web searches for Masonic ciphers quickly surface pigpen.<sup>[11](https://www.srmml.org/magicians-magic-movements-and-ceremonies/)</sup>

## Cryptanalysis

Pigpen provides no additional security over substituting other letters. It is a simple monoalphabetic substitution using symbols instead of letters, cryptographically equivalent to the [Caesar cipher](https://www.edgepedia.org/caesar-cipher) or any other fixed letter-to-symbol mapping, and breakable by the same frequency analysis.<sup>[2](https://ciphermuseum.com/ciphers/pigpen.html)</sup> The most common symbols in a pigpen message correspond to the most common letters of the source language, E, T, A, O, I, and N in English, and once enough letters are identified, partial words become legible and context fills in the rest.<sup>[12](https://caesarcipher.org/learn/pigpen-cipher-masonic-history-variations)</sup><sup> • </sup><sup>[13](https://matheverywhere.pages.oit.duke.edu/course/Modules/cryptography/notes.html)</sup> Breaking a pigpen message is not very difficult as long as the solver can recognize the symbols, and short messages offer less text for analysis but can still fall to common guesses.<sup>[7](https://www.cerias.purdue.edu/education/k-12/teaching_resources/lessons_presentations/activitysheet01.pdf)</sup><sup> • </sup><sup>[14](https://www.itechguides.com/how-to-write-using-codes-and-secret-ciphers/)</sup>

A practical wrinkle is that printed keys vary. Printed pigpen keys differ in details such as grid order and whether dots or a Maltese-cross layout are used, so two printed keys may not match cell-for-cell; correspondents should confirm they are using the identical key.<sup>[5](https://dotdashkey.com/reference/pigpen-cipher/)</sup>

## Modern use

Modern use of pigpen is overwhelmingly recreational rather than genuinely concealing anything. Because its symbols strike a general audience as cryptic and intriguing without demanding any genuine [cryptanalysis](https://www.edgepedia.org/cryptanalysis), escape rooms and puzzle-hunt props reach for it; scouting groups and school cipher units adopt it as a practical first lesson in substitution ciphers; and Masonic or occult-themed fiction and games feature it over and over.<sup>[5](https://dotdashkey.com/reference/pigpen-cipher/)</sup> Educational institutions use it directly: NIST's National Initiative for Cybersecurity Education distributes a K-12 activity built on the cipher,<sup>[15](https://www.nist.gov/document/ccawpig-pen-cipher508compliantpdf)</sup> the International Spy Museum includes pigpen practice in its codes resource kit,<sup>[16](https://www.spymuseum.org/education-programs/educators/educator-resources/resource-kit-codes/)</sup> and museums such as Reading Museum run family workshops in which participants hunt for pigpen symbols and crack coded messages.<sup>[17](https://www.readingmuseum.org.uk/family-digi-workshop-code-breaking-%E2%80%93-pigpen)</sup>

The cipher's lasting appeal is visual. It takes the familiar shapes of the Latin alphabet and converts them into symbols that look ancient, mysterious, and intentional, which makes it a natural illustration of pre-digital encryption even though it offers little cryptographic security.<sup>[12](https://caesarcipher.org/learn/pigpen-cipher-masonic-history-variations)</sup><sup> • </sup><sup>[18](https://www.unidesktesting.motion.ac.in/oconstryctp/63F595P/lrasnu/40F380398P/codes%2Band%2Bciphers%2Ba%2Bhistory%2Bof%2Bcryptography.pdf)</sup>

## References

1. [Pigpen cipher, The Masonic Wiki](https://masonicwiki.org/wiki/Pigpen_cipher)
2. [Pigpen Cipher, The Cipher Museum](https://ciphermuseum.com/ciphers/pigpen.html)
3. [8 Ciphers That Shaped History, HISTORY](https://www.history.com/articles/ciphers-secret-codes-enigma-morse)
4. [Invisible Ink and More: The Science of Spying in the Revolutionary War, Scientific American](https://www.scientificamerican.com/podcast/episode/invisible-ink-and-other-science-of-10-04-20/)
5. [Pigpen Cipher — Full Reference Chart, DotDashKey](https://dotdashkey.com/reference/pigpen-cipher/)
6. [](https://people.sc.fsu.edu/~jpeterson/cryptography.pdf)
7. [The Pigpen Cipher, Purdue CERIAS activity sheet / Florida State cryptography notes](https://www.cerias.purdue.edu/education/k-12/teaching_resources/lessons_presentations/activitysheet01.pdf)
8. [Invitation to Cybersecurity, Cedarville University](https://publications.cedarville.edu/cedrus_press/invitation_to_cybersecurity/149/)
9. [Read 'Em Again Books catalog: Masonic Royal Arch Cypher manuscript (1839)](https://read-em-again.cdn.bibliopolis.com/images/upload/catalog-26-3-for-printing.pdf)
10. [Sources of Alchemical Cryptography, University of Tartu dSpace](https://dspace.ut.ee/bitstreams/18c0caf0-518f-4329-ad7f-8c2ad121f0cc/download)
11. [Magicians' Magic Movements and Ceremonies, Scottish Rite Masonic Museum & Library](https://www.srmml.org/magicians-magic-movements-and-ceremonies/)
12. [Pigpen Cipher History: From Masonic Lodges to Pop Culture Phenomenon, CaesarCipher.org](https://caesarcipher.org/learn/pigpen-cipher-masonic-history-variations)
13. [Cryptography Course Notes, Math Everywhere, Duke University](https://matheverywhere.pages.oit.duke.edu/course/Modules/cryptography/notes.html)
14. [How to Write Secret Messages: Codes and Ciphers Explained, ITechGuides](https://www.itechguides.com/how-to-write-using-codes-and-secret-ciphers/)
15. [Cybersecurity CyberSnack: Pig Pen Cipher, NIST NICE K-12](https://www.nist.gov/document/ccawpig-pen-cipher508compliantpdf)
16. [SPY Resource Kit: Codes, International Spy Museum](https://www.spymuseum.org/education-programs/educators/educator-resources/resource-kit-codes/)
17. [Family Digi-Workshop: Code Breaking – Pigpen, Reading Museum](https://www.readingmuseum.org.uk/family-digi-workshop-code-breaking-%E2%80%93-pigpen)
18. [Codes and Ciphers: A History of Cryptography (PDF)](https://www.unidesktesting.motion.ac.in/oconstryctp/63F595P/lrasnu/40F380398P/codes%2Band%2Bciphers%2Ba%2Bhistory%2Bof%2Bcryptography.pdf)

---
*Topic: Encyclopedia › Physical world and mathematics › Mathematics and statistics › Logic and discrete mathematics › General discrete mathematics and discrete structures › Discrete mathematics*

*Initially written Sep 17, 2026 · Reviewed: Oct 15, 2026 · Edited: Oct 15, 2026 · Last review: Oct 15, 2026*

*Copyright 2026 EdgeChat AI, a subsidiary of Biostate AI.*

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license
