1. Home
  2. Writing & text tools
  3. Rail Fence & Columnar Transposition

Rail Fence & Columnar Transposition

Scramble the order of letters rather than replace them: write the message in a zigzag across rails, or in rows under a keyword, and read it off another way.

Free, no sign-up. Runs in your browser: nothing is uploaded.

How to use Rail Fence & Columnar Transposition

  1. Choose rail fence or columnar.
  2. Set rails and offset, or the keyword.
  3. Type the text and read the zigzag or grid.

Features

  • Rail fence with 2–20 rails and an offset
  • Columnar transposition, irregular or padded with X
  • Zigzag and grid diagrams
  • Spaces kept or removed
  • This is a classical cipher for puzzles, games and teaching. It does not protect real secrets.

Supported formats

You can open

  • Typed or pasted text
  • TXT

You get

  • Copied text
  • TXT

Private by design

Your files are opened and processed by your browser on this device. They are never uploaded to openWorkstand or anyone else, so the Rail Fence & Columnar Transposition is safe for contracts, IDs, photos and work documents. After you have used it once while online, it also works without an internet connection. How local processing works

Good to know

  • A classical cipher for puzzles and teaching: it can be broken quickly and must not be used to protect real secrets.

Guide

Rail fence and columnar transposition ciphers, step by step

Most classical ciphers replace letters with other letters. Transposition ciphers keep every letter exactly as it is and change the order instead. The two classic forms are the rail fence, which writes the message in a zigzag, and columnar transposition, which writes it in rows under a keyword and reads it by columns. This tool does both, and draws the zigzag or the grid so you can see what happened.

The rail fence cipher

Write the message diagonally down and up across a number of “rails”, like the rails of a fence. With three rails, WEAREDISCOVERED becomes W . . . E . . . on the top rail, E . R . D . S . on the middle and so on. Reading each rail from left to right gives the cipher text. The tool shows the zigzag with dots for empty positions. The classic example “We are discovered, flee at once” with three rails gives WECRLTEERDSOEEFEAOCAIVDEN.

Rails and offset

More rails scramble the order more. The offset starts the zigzag partway into its cycle, which changes the result without changing the rail count. Spaces are removed by default, as is traditional; keep them if you want them to move with the letters.

Columnar transposition

Write the message in rows under a keyword, one letter per column. Number the columns by the alphabetical order of the keyword’s letters, then read the columns down in that order. With the keyword ZEBRAS, the column under A is read first, then B, E, R, S and finally Z. The grid diagram shows the keyword, the column numbers and the rows.

Irregular or padded

If the last row is not full, the cipher is “irregular”: some columns are one letter shorter, which makes the cipher harder to break. Turn on padding to fill the last row with X so every column has the same length, as some textbooks do. Decryption works out the column lengths from the keyword and the message length, so both forms decrypt correctly — just use the same setting on both sides.

Decrypting and breaking

Decrypting with the right key reverses each step exactly. Without the key, transposition ciphers still have a weakness: the letters are the same as in normal English, so the frequencies of e, t, a and o look normal, which tells an analyst immediately that the cipher is a transposition. With few rails, simply trying each number breaks a rail fence in seconds.

Uses

Rail fence ciphers are a gentle introduction to cryptography for children. Columnar transposition appears in puzzle hunts and in the history of real military ciphers, including the double transposition used in both world wars.

A worked example

With three rails, HELLOWORLD is written in a zigzag: H, O and L on the top rail; E, L, W, R and D on the middle; L and O on the bottom. Reading the rails in order gives HOLELWRDLO. To decrypt, the tool rebuilds the same zigzag pattern, places the letters of HOLELWRDLO back on the rails and reads along the zigzag, giving HELLOWORLD again. The diagram under the result shows exactly this pattern with dots for the empty positions.

Combine transposition with substitution using the Playfair Cipher, try the Caesar Cipher Solver or the Vigenère Cipher, or simply flip text with Reverse Text.

Checked against the current version of the Rail Fence & Columnar Transposition on .

Troubleshooting

The file does not open

Check that it is one of the supported formats above and opens in another app. Damaged files and password-protected PDFs cannot be read until they are repaired or unlocked.

It is slow or stops on a very large file

Everything runs on your device, so speed depends on its memory. Close other tabs, use a computer rather than a phone, or split the file into smaller parts first.

The download did not start

Look for your browser’s download bar or icon. Some browsers ask once before a site may download files; allow it and click the button again.

Frequently asked questions

What does the offset do in a rail fence cipher?

It starts the zigzag partway through its cycle instead of on the top rail. Both sides must use the same offset; it is a small extra twist that puzzle makers use to stop the obvious decryption.

How do repeated letters in a keyword affect the column order?

Equal letters are numbered from left to right. In the key LETTER, the two Es come first (1 and 2), then L (3), R (4) and the two Ts (5 and 6), so the order is always well defined.

What is a double transposition?

Applying columnar transposition twice, usually with two different keywords. It was a serious field cipher in both world wars. Encrypt once, copy the result back into the input and encrypt again with the second key.

How do I decrypt a rail fence cipher without the number of rails?

Try 2, 3, 4 and so on in decrypt mode; with only a handful of possible values, the readable result stands out quickly.

What is the difference between irregular and padded columnar transposition?

Padded fills the last row with X so every column has the same length. Irregular leaves the last row short, which is harder to break and is the usual form.

Keep working with the result

After you download, choose “Save to Workstand” to keep the result in a folder on your computer, attach it to a project and create a follow-up task. It is saved by your browser, not uploaded.