Columnar Transposition Cipher Decoder, Encoder & Solver
TL;DR: Encode or decode with a keyword, or solve unknown keys of 2–7 letters. Write across rows, then read down columns in keyword order.
By Hommer Zhao · Updated October 29, 2026
How columnar transposition works
A keyword sets the grid width and the column order. With CODE, the labels in alphabetical order are C, D, E, O, so read original columns 1 → 3 → 4 → 2. These are column positions, not new letters substituted for the message.
- Write the message left to right across rows under the keyword.
- Sort the keyword letters alphabetically, ignoring case. Break repeated-letter ties from left to right:
LETTERgives 2 → 5 → 1 → 6 → 3 → 4, the common columnar convention. - Read each selected column from top to bottom. In an irregular grid, skip empty cells.
- To decode, determine each original column’s length, refill columns in sorted-key order, then read rows left to right.
| C (1) | O (2) | D (3) | E (4) |
|---|---|---|---|
| M | E | E | T |
| A | T | N | O |
| O | N | — | — |
The irregular ciphertext is MAOENTOETN. For any length N and width k, each column has floor(N/k) characters; the leftmost N mod k original columns receive one extra. Work out these lengths before sorting the columns.
This tool keeps spaces and punctuation as grid characters. For a traditional letters-only exercise, remove them before encoding. A numeric keyword is sorted one digit at a time; for example 3142 means read columns 2, 4, 1, 3.
Complete vs irregular columnar
Complete columnar fills the rectangle. Here, encoding adds X to finish the final row; an already full row gets no extra padding. Every column has the same length, and ciphertext length must be divisible by the key length.
Irregular columnar leaves the final row unfinished and adds nothing. The leftmost original columns can be one character longer than the rest. This is the default, so a round trip preserves the exact input.
In the ten-character CODE grid above, columns 1 and 2 have three characters; columns 3 and 4 have two. Irregular decoding splits the ciphertext into lengths 3, 2, 2, 3 in read order 1, 3, 4, 2. Complete encoding instead adds two X characters, giving four columns of three.
The decoder retains all trailing X characters. Remove them only when the sender or exercise confirms they are filler; an X may be part of the real message.
Decode dtinaxonxopc with keyword CODE
The literal decoded result is donotpanicxx. With the instruction to ignore trailing X padding, it becomes donotpanic: “do not panic.” Word spaces are restored for readability.
- The ciphertext has 12 characters and CODE has four letters: the rectangle has three rows. Complete and irregular decoding give the same grid here.
- Sort CODE into C, D, E, O. The column read order is 1 → 3 → 4 → 2.
- Split ciphertext into four three-character chunks:
dti | nax | onx | opc. - Place each chunk top to bottom in its original column: dti → C (column 1); nax → D (column 3); onx → E (column 4); opc → O (column 2).
- Read each completed row left to right, then continue to the next row.
| C (1) | O (2) | D (3) | E (4) |
|---|---|---|---|
| d | o | n | o |
| t | p | a | n |
| i | c | x | x |
dono / tpan / icxx → donotpanicxx
The two final x characters can be ignored for this exercise. Keeping them in the tool’s output makes the decode reversible and avoids deleting genuine message characters.
How well does the short-key solver work?
Across 120 fixed English samples, the original plaintext ranked first in 53 and appeared in the top five in 79. Treat candidates as suggestions to read, not guaranteed answers.
| True key length | Samples | ResultsRank 1 | Top 5 | Orders searched |
|---|---|---|---|---|
| 3 | 24 | 12 | 15 | 90,034 |
| 4 | 24 | 13 | 18 | 98,388 |
| 5 | 24 | 11 | 17 | 81,168 |
| 6 | 24 | 10 | 16 | 80,424 |
| 7 | 24 | 7 | 13 | 131,750 |
We used 12 traditional public-domain English proverbs, including “A stitch in time saves nine.” Each was converted to uppercase letters only and encrypted at key lengths 3–7, once with X padding and once without. A seeded shuffle (seed 20261029) chooses the keyword for each pair.
The solver is told the grid format, but not the original key length. It searches 2–7 together, just like the unknown-length option above. Complete mode tests only divisors of the ciphertext length; irregular mode tests all 5,912 orders. At a single known length, the count is k!: 6, 24, 120, 720 or 5,040 for lengths 3–7.
Success means exact plaintext recovery, including padding, among five distinct outputs. Tied scores prefer a shorter key, then the earlier column order. Duplicate plaintexts occupy one result slot; every attempted order still counts. This small fixed sample is not a general accuracy estimate, and the two formats coincide when no padding is needed.
Ranking reuses the cipher identifier’s English heuristic and adds counts of common two- and three-letter sequences. Letter-frequency counts alone cannot distinguish column orders because transposition preserves them. Short messages, names, non-English text and long keys need more clues; the search covers one transposition with at most seven columns.
Download the reproducible results (JSON), including all 12 sentences, seeded keys, ciphertexts, expected plaintexts, candidate scores, search counts and the regeneration command.
Download the source snapshot (ZIP, October 29, 2026 · r2) for the generator, codec, English scorer, corpus and all required source files. Extract it, then run node verify.mjs with Node.js 22.18 or later to regenerate and verify the results. No packages or network access are needed.
The implementation revision and SHA-256 manifest (JSON) identifies the exact source snapshot and original results file. The benchmark measures the first five candidates; Show more candidates lets you inspect additional results without changing the ranking.
History: transposition in wartime systems
During World War I, the German Army used ADFGX and then the six-symbol ADFGVX system in 1918. William F. Friedman’s Military Cryptanalysis, Part IV, Section IX, paragraph 37, printed page 97, describes the substitution checkerboard followed by keyed columnar transposition. This combined system is different from simply rearranging the original message letters. An Internet Archive text copy is also available.
Double transposition is also documented in the 1944 Bletchley Park Cryptographic Dictionary. These historical systems illustrate how a simple grid operation could be repeated or combined with substitution. Today this tool is suited to puzzles, classroom exercises and studying those methods.
Frequently asked questions
What is a columnar transposition cipher?
It is a classical cipher that places plaintext into rows under a keyword and reads the columns according to the sorted keyword order. The plaintext characters stay the same, but their positions move.
Is columnar transposition secure by modern standards?
No. It is historically important and useful for learning, but it is not secure against modern cryptanalysis. It belongs to the family of classical hand ciphers, not modern encryption systems.
What kind of key should I use?
Any short keyword or numeric sequence can work. Longer keys create wider grids, but both sender and receiver must apply the same column order. This tool removes whitespace from the key and sorts its characters individually, ignoring case. Numeric keys are digit labels, not a list of column numbers to read directly.
How does this tool handle spaces and punctuation?
By default the tool keeps spaces, punctuation, and case exactly as entered. Turning off Preserve input case uppercases the letters but still keeps spaces and punctuation. Remove them before encoding if you want a letters-only worksheet. Remove ciphertext grouping spaces only when they were added for display.
Does columnar transposition change the letters themselves?
No. A transposition cipher keeps the original letters but rearranges their order. That is the main difference between transposition ciphers and substitution ciphers such as Caesar or Vigenere. Complete mode also adds X padding to fill the last row.
Can repeated letters appear in the keyword?
Yes. This tool uses the common left-to-right tie rule: equal keyword letters are read in their original column order. For LETTER, the column read order is 2, 5, 1, 6, 3, 4. This is ordinary columnar transposition; it does not use the different Myszkowski repeated-letter rule.
How do you decode a columnar transposition without the key?
Choose Solve without the key, enter the ciphertext, and select its grid format. Try a known key length or search lengths 2 through 7 together. The solver tests every column order and initially displays five distinct plaintexts ranked by an English sequence score. Choose Show more candidates to inspect the remaining results, then Use this candidate to load its equivalent numeric keyword into Decode. Inspect the words and context: short text can rank incorrectly, and this search does not cover longer keys or double transposition.
Should I remove trailing X characters after decoding?
Only when the message instructions identify them as padding. Complete encoding adds X characters to finish the last row, but a genuine message may also end in X. The decoder keeps every character. For dtinaxonxopc with keyword CODE, the literal result is donotpanicxx; ignoring the specified trailing padding gives donotpanic, or “do not panic” with word spaces restored.