About Rail Fence Cipher
Rail Fence Cipher encrypts and decrypts text with the classical rail fence transposition, one of the oldest ciphers there is. It writes the message in a zig-zag down and up a set of rails, then reads each rail in turn to produce the ciphertext - a scrambled string of the same length and characters.
You give it a text, a number of rails and a mode, and the tool performs the corresponding pass. The default of HELLO WORLD with three rails encrypts to HOREL OLLWD, and decrypting that string returns the original. The rail count is clamped to a range of two to ten, and the mode defaults to encrypt when the selector is missing.
The honest framing matters here: this is a classical transposition cipher with no security. Every character - spaces and punctuation included - is moved but not changed, and the only key is the rail count, so the result is trivially breakable by hand. It belongs in puzzles, games and teaching, never in anything that must stay secret.
How to use Rail Fence Cipher
- 1 Type or paste the text you want to scramble or unscramble.
- 2 Set the number of rails, or leave the default of three.
- 3 Choose Encrypt or Decrypt, then run the tool.
Frequently asked questions
How does the rail fence work?
The text is written in a zig-zag down and up the rails, then each rail is read in order. HELLO WORLD with three rails becomes HOREL OLLWD, and decrypting reverses the process.
Is this a secure cipher?
No. It is a classical transposition with no key beyond the rail count, and it is trivially breakable by hand. Use it for puzzles and teaching, not for anything that must stay secret.
What happens to spaces and punctuation?
They are transposed like letters rather than stripped or preserved separately, so the ciphertext has the same length and character set as the input and the layout is not hidden.
Does the mode default to anything?
Yes, encrypt. If the mode selector is missing, the tool encrypts, and the rail count is clamped to between two and ten.
Free, online, and private
Free to use
Rail Fence Cipher is completely free. There is no account to create, no login, and no hidden charge or usage limit.
Runs online in your browser
It is a free online tool that runs entirely in your browser. Nothing to download or install — open the page and start using it right away.
Your data stays private
All processing happens locally on your device. Your input is never uploaded, stored, or tracked, so it never leaves your browser.
How Rail Fence Cipher behaves in detail
These are the specifics of this implementation — the exact ranges, defaults and fixed settings you are working with.
| Parameter | Value |
|---|---|
| Input | a Text textarea starting at HELLO WORLD, a Rails number starting at three, and an encrypt or decrypt selector |
| Mechanism | a zig-zag transposition that writes the text down and up a set of rails, then reads each rail in turn |
| Default | HELLO WORLD with three rails encrypts to HOREL OLLWD |
| Round-trip | decrypting an encrypted string returns the original text |
| Rails clamp | the rail count is clamped to the range from two to ten |
| Case | spaces and punctuation are transposed like letters, not stripped or preserved separately |
Compiled from the implementation of this tool and checked against it by itoolnet.
What Rail Fence Cipher does not do
Knowing the edges of a tool saves more time than another list of its features. These are the cases where it will not do what you might expect.
- This is a classical transposition cipher with no security. It is trivially breakable by hand and offers no key beyond the rail count, so it belongs in puzzles and teaching, never in anything that must stay secret.
- Every character is transposed, including spaces and punctuation, so the ciphertext carries the same length and character set as the input and the layout of the text is not hidden.
- The mode defaults to encrypt when the selector is missing, and there is no key material beyond the number of rails - no passphrase, no padding and no way to vary the pattern.
Tested and documented by itoolnet, the team that builds and maintains this site.