PB
Available
swap_horiz
lock Free · Private · In-Browser

Rail Fence Cipher

Encode or decode the zigzag rail fence transposition cipher.

The zigzag transposition cipher

The rail fence cipher writes your message in a zigzag across several rows, then reads the rows in order to scramble it. It is a transposition cipher — the letters are rearranged rather than replaced — and a favourite of puzzle books.

With three rails, WEAREDISCOVEREDFLEEATONCE encodes to WECRLTEERDSOEEFEAOCAIVDEN, and decoding with the same rail count restores it. More rails means a longer zigzag and more mixing.

A puzzle cipher, kept private

It offers no real security, but the encoding and decoding both run in your browser so your text stays on your device.

Frequently Asked Questions

How does the rail fence cipher work?

Letters are written in a zigzag down and up across a set number of rails, then read off row by row. Decoding rebuilds the zigzag and reads it in order.

What does the rail count change?

More rails scramble the text more, but it remains a simple transposition — the letters are only rearranged, not substituted.

Is it secure?

No. It is a classic puzzle cipher, easily broken, and should never be used to protect real information.

Take it further
All Free Tools

Browse the full set of free, private, in-browser tools.

Learn More arrow_forward