Converter Tools
Rail Fence Cipher
Encode and decode the rail fence (zigzag) cipher in your browser. Adjustable rails, optional offset, letters-only mode, and a live fence diagram.
The number of horizontal lines the zigzag bounces between. Both sides must use the same rail count.
How many steps into the zigzag the first character starts. Leave at 0 for the standard cipher.
30 characters will be encoded across 3 rails.
Cipher text
WRIVDETCEAEDSOEE LEA NE CRF O
Fence diagram
How the characters sit on the zigzag. Reading each row left to right, top to bottom, gives the cipher text.
Spaces are shown as a middle dot so the layout stays readable. The faint dots mark empty positions on each rail.
How to use
- Choose Encode to scramble a message or Decode to recover one.
- Type or paste your text into the input box.
- Set the number of rails, and make sure the sender and receiver use the same count.
- Optionally add a start offset or turn on letters-only mode to match a specific variant.
- Read the result, watch the fence diagram, and copy the output or send it to the other mode.
About this tool
Rail Fence Cipher encodes and decodes the classic zigzag transposition cipher entirely in your browser. The cipher works by writing your message diagonally down and up across a fixed number of horizontal rails, then reading the letters off one rail at a time to produce the ciphertext. To decode, the tool rebuilds the same zigzag path, refills the rails from the cipher text in order, and reads the message back along the path. You can set the number of rails from 2 to 12, add an optional starting offset for textbook variants that begin partway through the zigzag, and switch on letters-only mode to strip spaces and punctuation the way the cipher is usually taught. A live fence diagram draws exactly where every character lands on the zigzag, which makes it easy to follow the transformation and check your work by hand. Because it is a transposition cipher, it rearranges your letters rather than substituting them, so it pairs naturally with substitution ciphers like Caesar, Vigenere, and Atbash. It is handy for puzzle hunts, capture-the-flag challenges, escape rooms, geocaching mystery caches, and classwork on classical cryptography. The rail fence offers no real security against modern attacks, so treat it as a learning and puzzle tool rather than protection for sensitive data. Everything runs locally, so the text you type is never uploaded.
Free to use. Works in your browser. No signup, no login.
Related tools
You may also like
Caesar Cipher Encoder / Decoder
Encode, decode, or brute-force Caesar shift ciphers with ROT13 and frequency ranking.
Open tool
ConverterVigenere Cipher Encoder / Decoder
Encode or decode Vigenere ciphers with standard, Beaufort, and autokey variants.
Open tool
ConverterAtbash Cipher
Encode or decode Atbash cipher text in Latin or Hebrew with a live mapping table.
Open tool