Rail Fence Cipher Encoder / Decoder
Free rail fence cipher encoder and decoder. Choose the number of rails, optionally keep spaces and punctuation, visualize the zigzag, and encode or decode your message.
Full original guide (expanded)
Rail Fence Cipher Encoder / Decoder
Encode or decode text with the classical rail fence cipher. Set the number of rails, decide whether to keep spaces and punctuation, and view the zigzag pattern to understand how the cipher works.
Chars processed
—
Rails used
—
Mode
—
Zigzag for current text and rail count (first ~40 characters shown).
How the rail fence cipher works
The message is written diagonally across several rows (rails) and then read off row-by-row.
Example: plaintext = WEAREDISCOVEREDFLEEATONCE, rails = 3
Write in zigzag:
W . . . E . . . C . . . R . . . L . . . T . . . E . E . R . D . S . O . E . E . F . E . A . O . C . . . A . . . I . . . V . . . D . . . E . . . N . .
Read row by row ⇒ WECRL TEERD SOEEF EAOCA IVDEN (spaces added for clarity)
Decoder notes
To decode, we rebuild the zigzag: we first mark the pattern, fill rows with ciphertext, then read in zigzag order.
FAQ
- Does it preserve spaces? Yes, if you tick “Keep spaces/punctuation”.
- Is it secure? No: it’s a classical teaching cipher, good for puzzles.
Formula (LaTeX) + variables + units
','\
Example: plaintext = WEAREDISCOVEREDFLEEATONCE, rails = 3 Write in zigzag: W . . . E . . . C . . . R . . . L . . . T . . . E . E . R . D . S . O . E . E . F . E . A . O . C . . . A . . . I . . . V . . . D . . . E . . . N . . Read row by row ⇒ WECRL TEERD SOEEF EAOCA IVDEN (spaces added for clarity)
- No variables provided in audit spec.
- NIST — Weights and measures — nist.gov · Accessed 2026-01-19
https://www.nist.gov/pml/weights-and-measures - FTC — Consumer advice — consumer.ftc.gov · Accessed 2026-01-19
https://consumer.ftc.gov/
Last code update: 2026-01-19
- Initial audit spec draft generated from HTML extraction (review required).
- Verify formulas match the calculator engine and convert any text-only formulas to LaTeX.
- Confirm sources are authoritative and relevant to the calculator methodology.