Columnar Transposition Cipher
Encode and decode the columnar transposition cipher, a classic keyword-based scramble. Your text is written into a grid row by row beneath a keyword, and the columns are then read back in the alphabetical order of the keyword's letters — nothing is substituted, every character is simply moved. Choose irregular or complete columns, set a padding character, follow the live grid, and copy, download, or share the result. Everything runs in your browser.
Keyword
Enter a keyword. Its letters set the columns: the text is written across them row by row, then the columns are read out in the keyword's alphabetical order. Repeated key letters are taken left to right.
Enter text above to see the result here.
How to use Columnar Transposition Cipher
- 1
Choose encode or decode
Pick Encode to scramble plain text into columnar transposition cipher text, or Decode to turn cipher text back into the original message.
- 2
Choose irregular or complete columns
Irregular leaves the last row short and returns your text exactly. Complete pads the grid to a full rectangle with a character you choose, so every column is the same length.
- 3
Enter the keyword
Type a keyword. Its length sets the number of columns and the alphabetical order of its letters sets the order the columns are read. Both sides must use the same keyword; in Complete mode you can also set the padding character.
- 4
Type or paste your text
Enter your message and it is transposed as you type. The encoding grid shows your text filled into the keyed columns with each column's read order numbered.
- 5
Copy, download, or share
Copy the result, download it as a text file, or share a link that reopens the tool with your exact text, keyword, mode, and padding ready to go.
Understanding the Columnar Transposition Cipher
What is a columnar transposition cipher?
The columnar transposition cipher is one of the oldest and most intuitive ways to hide a message. It is a transposition cipher, which means it does not change any of the letters — it only changes their order. Every character in the cipher text is a character that was in the plain text; they have simply been shuffled according to a fixed, repeatable rule. That rule is set by a keyword, which makes the scramble easy to share with a trusted partner and hard to undo for anyone who does not know it.
The idea is to write the message into a grid, row by row, underneath the letters of the keyword, and then to read the grid back out one column at a time. The trick is the order in which the columns are read: not left to right, but in the alphabetical order of the keyword's letters. Because the keyword decides that order, two people who share the keyword can encode and decode freely, while the column order looks arbitrary to everyone else.
How the columnar transposition cipher works
Start by writing the keyword across the top of a grid, one letter per column. Then write the message beneath it, filling the first row left to right, then the second row, and so on, until the whole message is laid out. The number of columns is fixed by the length of the keyword, so a six-letter keyword always makes six columns regardless of how long the message is.
Now number the columns in the alphabetical order of the keyword's letters: the column under the keyword's earliest-in-the-alphabet letter is read first, the next-earliest second, and so on. If the keyword has two of the same letter, those columns are read left to right, in the order they appear. Finally, read the grid column by column in that numbered order, writing each column's letters out in turn. The string you get is the cipher text. To decode, you reverse the process: rebuild the empty grid, fill the columns back in their read order, and read across the rows.
Irregular versus complete columns
Most messages do not divide evenly into the grid, so the last row comes up short. In the irregular (or incomplete) form — the classic textbook columnar transposition — you simply leave those cells empty. The columns then differ in length by one, and the cipher text is exactly as long as the original message. This tool's Irregular mode does this, and it round-trips your text perfectly: decoding returns precisely what you typed, spaces and punctuation included.
In the complete form, you instead pad the message out to fill the final row, so every column is the same length and the grid is a perfect rectangle. The padding is usually a fixed, agreed letter such as X or Q, or a run of nulls. Complete columns make the column lengths obvious, which historically simplified pencil-and-paper work and is essential when the same grid is transposed a second time. Switch to Complete mode to pad the grid with the character of your choice; decoding then returns your text followed by whatever padding was added, which you can trim away.
The role of the keyword
The keyword does two jobs at once: its length sets how many columns the grid has, and the alphabetical ranking of its letters sets the order the columns are read in. A longer keyword makes a wider, shorter grid and a more thorough scramble; a keyword whose letters are already close to alphabetical order barely rearranges anything, so a well-mixed keyword is stronger. Only the relative order of the letters matters, which is why a keyword and any word with the same letter-ranking produce the same transposition.
Because the keyword is the whole secret, both sender and receiver must use exactly the same one. In this tool only letters in the keyword count toward the column order — spaces, digits, and punctuation are ignored — and repeated letters keep their left-to-right order, so a keyword like BANANA still gives a definite, reproducible column sequence. Change the keyword and the cipher text changes completely, while the same keyword always decodes it back.
A worked example
Take the message WE ARE DISCOVERED FLEE AT ONCE and the keyword ZEBRAS. Stripped of spaces the message is WEAREDISCOVEREDFLEEATONCE, twenty-five letters, and ZEBRAS has six letters, so we write it into six columns: WEARED on the first row, ISCOVE on the second, REDFLE on the third, EATONC on the fourth, and a final short row holding just E.
Now rank the keyword's letters alphabetically — A, B, E, R, S, Z — which numbers the columns 5, 3, 2, 4, 6, 1 from left to right. Reading the columns in that order gives EVLN from the A column, ACDT from the B column, ESEA from the E column, ROFO from the R column, DEEC from the S column, and finally WIREE from the Z column. Joined together, the cipher text is EVLNACDTESEAROFODEECWIREE. Feeding that and the keyword ZEBRAS into Decode rebuilds the grid and reads back WEAREDISCOVEREDFLEEATONCE.
Decoding a columnar transposition message
Decoding looks harder than encoding but follows the same grid. From the length of the cipher text and the number of columns in the keyword, you can work out exactly how tall each column is: if the message does not divide evenly, the left-most columns — the ones holding the earliest characters of each row — are one taller than the rest. Knowing each column's height lets you cut the cipher text back into its columns in the read order, drop each column back into its keyword position, and read across the rows to recover the message.
The only secret you need is the keyword; everything else is fixed by the cipher text itself. That is why this tool can decode purely from the cipher text and the keyword, with no extra information. Use the same keyword that was used to encode, and the same mode if padding was involved, and the original message reappears — for irregular columns it comes back exactly, and for complete columns it comes back with its padding, ready to trim.
History and security
Columnar transposition is centuries old and was a workhorse of field cryptography well into the twentieth century, valued because it needs nothing but paper, a keyword, and a steady hand. On its own it is not secure: because it never changes the letters, the cipher text has exactly the same letter frequencies as the plain text, and a cryptanalyst can attack it by guessing the number of columns and trying to slot the pieces back together — a technique called anagramming. Short messages and reused keywords fall especially quickly.
Its real strength comes from being combined with other steps. Running the transposition twice with two different keywords — double transposition — was considered strong enough for serious use for decades, and stacking transposition on top of a substitution is exactly what makes the ADFGVX cipher formidable. Today columnar transposition is best treated as a teaching tool and a puzzle: it is a clear, hands-on illustration of how rearranging letters hides a message. For protecting real information, use a modern, peer-reviewed algorithm such as AES, and keep columnar transposition for learning, puzzles, and capture-the-flag challenges.
Frequently asked questions
What is a columnar transposition cipher?
How does a columnar transposition cipher work?
What is the difference between complete and irregular columns?
Can you show a columnar transposition example?
How do you decode a columnar transposition cipher?
What does the keyword do?
What happens if the keyword has repeated letters?
Does the cipher keep spaces and punctuation?
What is the padding character for?
What is double transposition?
How secure is the columnar transposition cipher?
Is my text uploaded to a server?
Related tools
Keep going with these handy tools