Skip to content

↑↓ navigate ↵ open Esc close Search runs locally

Columnar Transposition Cipher: Encoder, Decoder & Solver

Write the message in rows under a keyword and read the columns in alphabetical order of the key. See the grid as you type, use a word or a number key, or let the solver find the key.

  • Runs in your browser
  • Nothing is uploaded
  • Free, no sign-up
0 chars
Columnar
Runs in your browser. Nothing is uploaded. Tip: Decrypt tries every key up to 6 columns

How to use the Columnar transposition tool#

  1. Choose Encrypt or Decrypt and type a Key: a word (its letters are ranked alphabetically) or numbers such as 3 1 2.
  2. Type or paste your text. Tick Letters only to remove spaces and punctuation first.
  3. Set Pad to a letter such as X to fill the last row (a regular transposition), or leave it empty for an irregular one.
  4. Look at the Grid to see the columns and their reading order. Don't know the key? In Decrypt mode, Key guesses tries every key up to 6 columns.

Examples#

Encrypt with the keyword ZEBRAS

Input
WE ARE DISCOVERED. FLEE AT ONCE.
Output
EVLNACDTESEAROFODEECWIREE

ZEBRAS ranks its letters A=1, B=2, E=3, R=4, S=5, Z=6, so the 5th column is read first.

Decrypt with the same key

Input
EVLNACDTESEAROFODEECWIREE
Output
WEAREDISCOVEREDFLEEATONCE

25 letters in 6 columns: the first column has 5 letters and the others 4, which decryption works out from the length.

Use a number key

Input
HELLOWORLD
Output
EORLWLHLOD

Column 2 (numbered 1) is read first, then column 3, then column 1.

What is the columnar transposition cipher?#

A columnar transposition writes the message in rows of a fixed width under a keyword, then reads the columns one after another in the alphabetical order of the keyword's letters. The letters do not change, only their order. It was widely used, often applied twice ("double transposition"), into the Second World War.

How it works#

With the keyword ZEBRAS, the letters are ranked alphabetically: A = 1, B = 2, E = 3, R = 4, S = 5, Z = 6. The message WEAREDISCOVEREDFLEEATONCE is written in rows of 6:

plaintext
Z E B R A S6 3 2 4 1 5-----------W E A R E DI S C O V ER E D F L EE A T O N CE

Reading the columns in order 1 to 6 gives EVLN + ACDT + ESEA + ROFO + DEEC + WIREE = EVLNACDTESEAROFODEECWIREE.

When a keyword has a repeated letter, the repeats are ranked from left to right. A number key such as 3 1 2 gives the reading order directly.

Regular and irregular transposition#

If the last row is not full, there are two options. A regular transposition pads the last row with filler letters (often X), so every column has the same length. An irregular transposition leaves the gaps, so some columns are one letter longer. To decrypt an irregular transposition, work out the column lengths from the message length: with 25 letters and 6 columns, the first column has 5 letters and the others 4.

How to break it#

For short keys, every column order can be tried: 6 columns have 720 orders. The solver here tries every key from 2 to 6 columns (873 in total) and ranks each result by how often common English letter pairs such as TH and HE appear. For longer keys, codebreakers use "anagramming": they line up columns side by side and look for pairs that form common English pairs and words.

Columnar vs rail fence#

Both are transposition ciphers. The rail fence cipher follows a fixed zigzag, and its only key is the number of rails, so it has very few keys. Columnar transposition uses a keyword, so the number of possible keys grows fast: a 10-letter key has 3,628,800 column orders.

Columnar transposition is not secure today. Even double transposition, a strong hand cipher, can be broken by computer.

Columnar transposition in code#

javascript
function columnar(text, key) {  const k = key.length;  const order = [...key].map((c, i) => [c, i]).sort().map(([, i]) => i);  const cols = Array.from({ length: k }, () => '');  [...text].forEach((ch, i) => { cols[i % k] += ch; });  return order.map((i) => cols[i]).join('');} columnar('WEAREDISCOVEREDFLEEATONCE', 'ZEBRAS'); // "EVLNACDTESEAROFODEECWIREE"

Common errors and fixes#

  • The result differs from another tool

    Check three things: whether spaces are removed (Letters only), whether the last row is padded (Pad), and how repeated key letters are ranked. This tool ranks repeats from left to right.

  • Decrypting a padded message leaves X letters at the end

    Padding letters are part of the ciphertext. Remove the trailing filler after decrypting.

  • The solver does not find my key

    The solver only tries keys up to 6 columns. Longer keys need the keyword, or manual anagramming of the columns.

Frequently asked questions#

How does the keyword decide the column order?

Each letter of the keyword is ranked alphabetically, and the columns are read from rank 1 upwards. In ZEBRAS, the column under A is read first and the column under Z last.

Can I use numbers as the key?

Yes. Type numbers such as 3 1 2 (or 312): the column with the smallest number is read first.

What is double transposition?

Applying a columnar transposition twice, usually with two different keys. It is much stronger than a single transposition and was used by several armies in both World Wars.

How do I decrypt without the key?

For keys up to 6 columns, choose Decrypt and read Key guesses: every order is tried and ranked by English letter pairs. Click a key to apply it.

Is my text uploaded?

No. Everything runs in your browser.

Your next tool is one search away.

Free, private developer tools that run in your browser. No signup, nothing uploaded, no waiting.

Browse all tools

Tip: press Ctrl D to bookmark dev247.