Skip to content
ToolsOnDuty - free online tools
Security & Cryptography

Rail Fence Cipher

Encode and decode text with the rail fence transposition cipher.

Free foreverRuns in your browserNo sign-up

The rail fence is a classic transposition cipher for puzzles and learning, not real security. Everything runs in your browser.

100% private - runs entirely in your browser.

Your input, keys and passwords are never uploaded. Want proof? Load this page, then turn off your internet - the tool still works. For an exact check, open your browser's DevTools Network tab and confirm no data is sent when you use it.

About the Rail Fence Cipher

Encode and decode text with the rail fence cipher, which writes letters in a zig-zag across a number of rails and then reads them off row by row.

You choose the number of rails, which changes the pattern.

It rearranges characters rather than substituting them, a classic transposition cipher.

Key features

  • Encode and decode modes
  • Adjustable number of rails (2 to 10)
  • Handles any characters
  • Copy the result instantly

How to use

  1. 1Choose encrypt or decrypt.
  2. 2Enter your text and the number of rails.
  3. 3Copy the result.

Examples

Encode
Input: WEAREDISCOVERED with 3 rails
Output: WECRUOERDSOEEREAIVD... reordered

Letters are read off the zig-zag rows in order.

Decode
Input: the cipher with 3 rails
Output: WEAREDISCOVERED

The same rail count rebuilds the original.

Frequently asked questions

What do rails do?
Rails are the rows of the zig-zag. More rails change how the characters are reordered, so the sender and receiver must use the same number.
Is it secure?
No. It is a classic transposition cipher for puzzles and learning, easily broken by trying a few rail counts.
Is my data uploaded?
No. Everything runs in your browser.