
Columnar Transposition Cipher
Write in rows, read columns by keyword alphabetical order - keyword permutation cipher.
Last reviewed: April 2026New to this tool? Click here for instructions
Encrypt and decrypt with the classical columnar transposition cipher — write your plaintext into a grid under a keyword, then read out the columns in the order the keyword dictates. Every computation runs in your browser; no plaintext or key ever leaves your machine.
What This Tool Does
Columnar transposition is a classical cipher that rearranges plaintext letters according to a keyword-derived column order. The plaintext is written into a fixed-width grid one row at a time, with the keyword's letters labeling each column. To encrypt, the columns are read out in the order given by the keyword letters' alphabetical ranking — column whose label is A first, then B, then C, and so on. The output is a permutation of the original plaintext characters with the same letter-frequency profile but a scrambled position order.
This tool supports both directions. Encryption pads the last row with X when needed, derives the column read order, and emits the ciphertext in five-letter groups (the standard format for hand-written cryptograms). Decryption reverses the process: given the ciphertext and the keyword, the tool computes how many letters fall in each column, distributes the ciphertext across columns in the correct read order, then reads the grid row-wise to recover the plaintext. The step-by-step view renders the underlying grid with column rank numbers highlighted so you can trace the construction by eye.
Everything happens client-side. There is no server round-trip, no telemetry on your messages, and no logging of the keyword you pick. Close the tab and the state is gone.
How to Use It
Type a keyword into the keyword field at the top — any string of letters works, though 5 to 10 characters is the practical sweet spot. Choose Encrypt or Decrypt in the mode chips. Enter your text in the left pane and the result appears live in the right pane as you type. The status bar at the bottom confirms the active keyword, column count, and row count so you can verify the grid dimensions match what you expect.
Click Step-by-Step to reveal the grid view beneath the main panes. Each column header shows the keyword letter at the top and its derived read-order rank in green below, so you can see exactly which column is read first, second, third, and so on. The grid populates with the actual padded plaintext for the active encryption, with any pad characters added to fill the last row shown in muted italic.
The Try Example button loads the canonical demonstration message WE ARE DISCOVERED FLEE AT ONCE with key ZEBRA — the same example used in textbooks and in the worked walkthrough below. The Copy button copies the ciphertext exactly as displayed (five-letter groups for encryption, contiguous for decryption). Spaces and punctuation in the input are stripped automatically, and the parser is case-insensitive: zebra and ZEBRA produce the same key.
Worked Example: Encrypt WE ARE DISCOVERED FLEE AT ONCE with Key ZEBRA
This is the textbook example for columnar transposition and a quick way to sanity-check any implementation. Click Try Example to load it directly into the tool.
- Strip non-letters and uppercase. The input
WE ARE DISCOVERED FLEE AT ONCEbecomesWEAREDISCOVEREDFLEEATONCE— 25 letters. - Derive column ranks from the keyword. ZEBRA has letters Z, E, B, R, A. Sorted alphabetically: A, B, E, R, Z. So A=1, B=2, E=3, R=4, Z=5. Mapped back to the original positions: Z=5, E=3, B=2, R=4, A=1. The column read order is therefore 5-3-2-4-1 (read column A first, then B, then E, then R, then Z last).
- Fill the grid row by row. Five columns means each row holds five letters: row 1 is
W E A R E, row 2 isD I S C O, row 3 isV E R E D, row 4 isF L E E A, row 5 isT O N C E. With 25 letters in 5 columns the grid is exactly filled — no padding needed. - Read columns in rank order. Column A (read order 1) holds positions 5, 10, 15, 20, 25 — that's E, O, D, A, E. Column B (read order 2) holds positions 3, 8, 13, 18, 23 — A, S, R, E, N. Column E (read order 3) holds positions 2, 7, 12, 17, 22 — E, I, E, L, O. Column R (read order 4) holds positions 4, 9, 14, 19, 24 — R, C, E, E, C. Column Z (read order 5) holds positions 1, 6, 11, 16, 21 — W, D, V, F, T.
- Concatenate to produce the ciphertext. Joining the columns in read order:
EODAE ASREN EIELO RCEEC WDVFT. Compare against the tool output to confirm the implementation is correct.
The diagram below shows the same construction visually: plaintext written row by row into the grid, then columns extracted in the order ranked by the keyword letters.
Common Use Cases
Historical cryptography education. Columnar transposition sits at a useful pedagogical sweet spot: complex enough to demonstrate genuine permutation (unlike monoalphabetic substitution), simple enough that students can encrypt and decrypt by hand in a single class period. It appears in every introductory cryptography textbook from Stinson's Cryptography: Theory and Practice to Singh's The Code Book, and instructors use it to motivate the eventual transition to product ciphers that combine substitution and permutation — exactly the structure modern AES inherits.
CTF and puzzle challenges. Capture-the-flag competitions regularly include transposition challenges in their crypto categories. The classic move is to obfuscate the keyword: hide it as a substring in another clue, derive it from a Caesar shift of another piece of text, or chain transposition with substitution to force solvers through multiple stages. Once you recognize the ciphertext has the same letter frequencies as English (suggesting transposition rather than substitution), columnar is one of the first hypotheses to test.
Puzzle and escape-room design. Game designers favor columnar transposition because it produces ciphertext that looks superficially encrypted but is solvable by hand within the time budget of a puzzle session. Combined with a thematic keyword tied to the puzzle's narrative, it rewards solvers for paying attention to story details while staying mechanically straightforward.
Understanding the classical-to-modern transition. Studying columnar transposition makes the design decisions inside AES easier to read. AES's ShiftRows step is itself a fixed-pattern row-level transposition; its MixColumns step is a linear mixing across columns. The fundamental insight that diffusion requires moving information between positions is exactly what transposition demonstrates — modern ciphers just iterate this insight many times with cryptographically chosen permutations rather than keyword-derived ones.
Edge Cases and Limitations
Irregular last row. When the plaintext length isn't a multiple of the key length, the final row has empty trailing cells. The two conventional fixes are pad characters (this tool uses X) and null columns (leaving the cells empty and recording per-column lengths separately). Padding is simpler but corrupts the plaintext's tail; nulls preserve the plaintext exactly but complicate decryption because the receiver must know which columns are short. This tool uses the padding convention to keep the encryption deterministic and the grid view rectangular.
Duplicate letters in the keyword. If the keyword contains repeated letters — say PIZZA — the alphabetical ranking has ties. The standard tie-break is left-to-right by original position: the first Z gets rank order 4 and the second Z gets rank order 5. The tool implements this rule consistently, so PIZZA, ZAPIZ, and similar keys with repeated letters produce predictable output.
Key length and security tradeoffs. Longer keys produce a larger keyspace (k! permutations for a k-letter key) but also create more columns, which means shorter individual columns. Very short columns are easier to attack by anagram solving because the per-column letter set is small. The historical sweet spot used by field cipher manuals sat between 7 and 12 characters — long enough to make brute force tedious by hand, short enough to keep columns substantive.
Double transposition for additional security. Applying columnar transposition twice with two different keywords meaningfully extends resistance to anagramming attacks. The columns from pass one are scrambled into new positions before pass two, destroying the per-column frequency signatures that single transposition leaks. Soviet diplomatic communications and World War II Allied agent codes both used double transposition extensively.
Anagram-based cryptanalysis on short messages. For ciphertexts under roughly 100 characters, the keyspace search and the anagram search converge quickly. A cryptanalyst tries each plausible key length (5 through 12), writes the ciphertext into that column count, then anagram-solves the rows by hand looking for valid English. This is fast enough that single columnar transposition on short messages is considered trivially broken even without a computer.
Key recovery via column-period detection. Even when the key is unknown, repeated common digrams in the plaintext (TH, HE, ER, AN) leave statistical traces. Cryptanalysts use the index of coincidence to detect the column period, then anagram the columns into recognizable text. The Friedman team formalized this attack against military transposition ciphers in the late 1930s.
Behind the History
Columnar transposition's recorded military use dates to the 1880s, when Russian nihilists adopted variations of it for revolutionary correspondence — keyword choices were typically poetic phrases that could be remembered without a written record, and the technique was deliberately chosen because it could be performed without specialized equipment. Decades later, this same accessibility made it attractive to wartime intelligence services that needed a cipher field agents could perform with pencil and paper alone.
The cipher's most famous deployment is the German ADFGX system, introduced in March 1918 and expanded to ADFGVX two months later. ADFGX combined a 5×5 Polybius substitution (letters chosen because their Morse code representations were maximally distinguishable over noisy telegraph lines) with a columnar transposition over the substituted output. The two-stage construction was significantly harder to break than either component alone — but French cryptanalyst Georges Painvin broke it in June 1918, partly by exploiting traffic from a single critical message known as the Radiogram of Victory. ADFGX is considered one of the most influential ciphers of World War I.
During World War II, Soviet diplomatic communications used double columnar transposition as one layer of their cipher stack. The VENONA project, a long-running American counterintelligence effort that decoded portions of intercepted Soviet traffic from 1942 onward, eventually exposed Soviet espionage in the Manhattan Project — though the breakthroughs came largely from one-time-pad key reuse rather than direct cryptanalysis of the transposition layer. The decryptions remained classified until 1995.
Systematic cryptanalysis of pure columnar transposition was formalized by the William Friedman team at the U.S. Army Signal Intelligence Service in the late 1930s. Their work on the index of coincidence and column-period detection turned what had been an artisanal codebreaking practice into a procedural method that could be taught and scaled, and it set the analytical foundations later used against ADFGX, Enigma, and beyond.
Cryptanalysis
Column-period detection via index of coincidence. The first step in attacking unknown columnar transposition is determining the key length. Write the ciphertext into candidate column counts (5, 6, 7, ... up to about 15), then compute the index of coincidence within each column. Natural English averages an IC of 0.067; uniform random text averages 0.038. When the candidate column count matches the true key length, each column's IC will sit near 0.067 because each column was filled with natural-language letters before transposition. Wrong widths produce a near-random IC distribution across columns.
Anagram solving for short blocks. Once the column count is identified, the columns are known up to permutation. For short ciphertexts (under 200 characters), the analyst writes each row across all columns and looks for an arrangement that produces valid English. Common digram frequencies (TH at 1.5%, HE at 1.3%, ER at 1.2%) give strong hints about which columns belong adjacent to each other. Computer-assisted anagram solving uses these digram frequencies as a scoring function to rank candidate column orderings.
Frequency analysis on columns when key length is known. If additional plaintext properties are known — for example, that the plaintext begins with a fixed header like REPORTS or contains a known signature line — the analyst can use the frequency profile of each column to anchor candidates. For double transposition, the same techniques apply but the search space is the Cartesian product of the two key permutations, which is why double transposition stayed field-secure significantly longer than single transposition.
Comparison: Columnar Transposition vs. Other Classical Ciphers
All of the ciphers in the table below are classical, all are considered broken against modern adversaries, and all are useful as teaching tools. The comparison highlights which type of weakness each cipher exhibits and the practical keyspace size — keyspace alone does not determine security (Vigenère's keyspace is huge but it is broken by Kasiski examination), but it sets a floor for the work required to break each one.
| Cipher | Type | Keyspace | Primary Weakness | Status |
|---|---|---|---|---|
| Caesar | Monoalphabetic substitution | 25 shifts | Brute force in 25 tries | Broken |
| Vigenère | Polyalphabetic substitution | 26k for key length k | Kasiski examination, IC analysis | Broken |
| Playfair | Digraph substitution | 25! permutations | Digram frequency, known-plaintext | Broken |
| Columnar Transposition | Transposition | k! for key length k | Anagram solving, IC column detection | Broken |
| ADFGX | Substitution + transposition (product) | 25! × k! | Two-stage cryptanalysis, traffic analysis | Broken (1918, Painvin) |
| Rail Fence | Transposition | Roughly 10 useful rail counts | Trivial brute force | Broken |
The key insight from this comparison is that combining cipher techniques (as ADFGX did) is dramatically more secure than any single technique. Modern ciphers like AES generalize this insight by iterating substitution and permutation across many rounds with cryptographically chosen — not keyword-chosen — components.