What the rail fence cipher is
The rail fence cipher, also called the zigzag cipher, is a transposition cipher: it keeps every letter and only changes the order. The message is written diagonally across a number of rows, the rails, going down to the bottom rail and back up again. Reading each rail from left to right gives the ciphertext.
The zigzag table under the tool draws this pattern for your own text.
Decrypting
To decrypt by hand, draw the empty zigzag for the message length and mark where each letter goes. Count how many marks fall on each rail, cut the ciphertext into pieces of those sizes, and write each piece along its rail. Then read the zigzag diagonally. The tool does this when you choose Decode.
How to break it
The only key is the number of rails, and it has to be smaller than the message length, so there are few options. Trying 2, 3, 4 and so on until the text reads normally breaks the cipher. The letter counts give it away too: they match normal English, because no letter was changed, only moved.
Questions about the rail fence cipher
How do I decode a rail fence cipher?
Choose Decode, paste the ciphertext and set the number of rails. If you do not know it, try 2, 3, 4 and so on; one of them will give readable text. There are only a few sensible values, so this takes seconds.
Is the rail fence the same as the zigzag cipher?
Yes. Both names describe writing the message in a zigzag across several rows and reading the rows one after another.
Does the tool keep spaces?
Yes. Spaces and punctuation are treated like letters and take their own place in the zigzag. Many puzzles remove spaces first; if yours did, remove them before encrypting so the result matches.
Is the rail fence cipher secure?
No. The letters are not changed, only moved, and the only key is the number of rails, so trying every rail count breaks it.
Is my text sent to a server?
No. Everything runs in your browser with JavaScript, and nothing you type leaves your device.