Ciphers · Rail fenceRail fence cipher online zigzag

In the rail fence cipher the letters are written in a zigzag across several rows, or rails, going down and up like a fence, and then read off rail by rail. WEAREDISCOVERED on three rails becomes WECRERDSOEEAIVD. The key is the number of rails, from 2 to 20; letters are not replaced, only reordered.

Everything runs in your browser — the text goes nowhere

01Encode02Diagram03How it works04Questions05Related
01

Encode

letters in a zigzag, then row by row
Rails
3
Plain text
Result
WECRERDSOEEAIVD
The link will contain the text (up to 500 characters) and settings — share it with care.
02

Diagram

a zigzag on 3 rails
W···E···C···R··
·E·R·D·S·O·E·E·
··A···I···V···D

Shows the first line of the text, up to 60 characters.

03

How it works

The zigzag

down · up · down

Letters go onto the rails one by one, top to bottom and back, like the rails of a fence.

Reading

rail by rail

The ciphertext is the top rail's letters, then the second rail's and so on: WEAREDISCOVERED → WECRERDSOEEAIVD.

Decoding

letters per rail

Knowing the number of rails and the length, you can count the letters on each rail and walk the zigzag again.

04

Frequently asked questions

The letters of the text go onto the rails in a zigzag: the first on the top rail, the second on the next one and so on down to the bottom, then back up. When the text runs out, you write down all the letters of the top rail, then the second rail, and so on. The diagram on this page draws the zigzag for your text.

Updated