LinguaholicTools

Rail Fence Cipher Encoder & Decoder

Encode and decode the rail fence cipher — a transposition cipher that writes text in a zig-zag across a set number of rails, then reads it off row by row.

Encoded
Horel ollWd

What is the rail fence cipher?

The rail fence cipher is a transposition cipher: instead of replacing letters, it rearranges them. You write the message in a zig-zag down and up across a set number of rows, or "rails," then read each row left to right to get the cipher text.

How to use it

  1. Choose Encode or Decode.
  2. Set the number of rails.
  3. Type your text and copy the result.

How the rail fence works

Picture the letters bouncing between the top and bottom rails in a zig-zag. Reading the rails top to bottom scrambles the order. The number of rails is the key: the sender and receiver must agree on it, and decoding rebuilds the zig-zag to restore the original order. The letters themselves never change, only their positions.

Where it is used

The rail fence is a great teaching example of transposition and a common step in multi-stage puzzles and escape-room clues.

More codes and ciphers

Explore the rest of the family: the Caesar Cipher, Atbash, Vigenère, and A1Z26. For other encodings, try the Morse Code Translator and the Binary Translator.

Free and private

This rail fence cipher tool runs entirely in your browser — free, with no sign-up, and nothing you type is uploaded or stored.

Frequently asked questions

What is the rail fence cipher?
The rail fence cipher is a transposition cipher: you write the message diagonally down and up across a number of 'rails' (rows), then read each row left to right to get the cipher text. It rearranges letters rather than replacing them.
How do I decode a rail fence cipher?
Choose Decode and set the same number of rails used to encode it. The tool rebuilds the zig-zag pattern and reads the letters back in the original order.
How many rails should I use?
Any number from 2 upward. More rails scramble short messages more, but the sender and receiver must agree on the exact rail count, since it is the key.
Is it free and private?
Yes — it runs entirely in your browser with no sign-up, and nothing you type is uploaded.