A rail fence cipher is the simplest kind of transposition. Most ciphers swap one letter for another. This one keeps every letter exactly as it is and only changes the order. You write the message diagonally down and up across a few rows (the rails), bouncing off the top and bottom like a zigzag fence, then read the rails one after another. It is also called the zigzag cipher.


How it works
Take HELP IS ON THE WAY on 3 rails (spaces are dropped). The letters land like this, one column per letter:
- Rail 1: H . . . I . . . T . . . A .
- Rail 2: . E . P . S . N . H . W . Y
- Rail 3: . . L . . . O . . . E . . .
Read each rail left to right and join them: HITA + EPSNHWY + LOE gives the cipher HITAEPSNHWYLOE.
Decoding it
Decoding is the same drawing run backwards, and you are told the number of rails.
- Count the cipher letters (14 here).
- Sketch the zigzag with 14 empty spots and count how many fall on each rail: 4, 7 and 3.
- Fill the rails in order: the first 4 letters go on rail 1, the next 7 on rail 2, the last 3 on rail 3.
- Read along the zigzag, down and up, and the message appears.
Two shortcuts: the first cipher letter is always the first letter of the message, and the first letter of rail 2 is always the second. One full V (down and back up) uses 2 × (rails − 1) letters, so 4 on 3 rails and 6 on 4 rails. Because nothing was swapped, counting letters tells you nothing here. It is all about where each letter belongs. And since there is no punctuation or spacing, look for short words like THE, AND and OF to find where words start and stop.
The card at the top shows Rails: N, from 2 to 6, and the board shows the cipher with a gap after each rail so you can see how many letters each one holds. You type the message in reading order. Under the board, a zigzag helper has already placed each rail's letters for you, and the box you pick gets outlined in the fence. In Options, under Display, Show rail fence is that helper (turn it off to draw the zigzag yourself) and Highlight errors when complete marks wrong letters once every box is filled. There is no frequency table for Rail Fence, because none of the letters change. Print / share makes a worksheet with each rail in its own block and room to write the message underneath, so you can practice on paper.
Codebusters
Rail Fence is not on the 2027 Science Olympiad Division C Codebusters list. It has appeared in earlier seasons, usually with the number of rails given, and it is still great training for the transposition thinking you need for Complete Columnar, which is on the 2027 list.
Practice it
In the app's Reference & Flashcards screen, the English Patterns by Frequency deck drills the most common English words, which helps you spot them in a long run of letters with no spaces. Flip the cards, swipe them into Know or Still learning, then try the multiple-choice Test. Not sure how many rails a message uses? Try each count in turn. The wrong ones read as nonsense from the start, and the right one gives words.


