T

Text Machine

Powerful text tools, in your browser

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

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.

Plain text
Cipher text

Enter text above to see the result here.

How to use Columnar Transposition Cipher

  1. 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. 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. 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. 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. 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?
It is a classic transposition cipher that hides a message by reordering its letters rather than replacing them. You write the message into a grid row by row under a keyword, then read the columns back out in the alphabetical order of the keyword's letters. The keyword is the shared secret: anyone who knows it can encode and decode, while the column order looks arbitrary to everyone else.
How does a columnar transposition cipher work?
Write the keyword across the top of a grid, one letter per column, then fill the message in beneath it row by row. Rank the keyword's letters alphabetically to number the columns, then read the grid one column at a time in that numbered order. The letters you read out, joined together, are the cipher text. Decoding rebuilds the same grid and reads across the rows.
What is the difference between complete and irregular columns?
Irregular (incomplete) columns leave the last row short when the message does not fill the grid evenly, so the columns can differ in length by one and the cipher text is the same length as the message. Complete columns pad the message out to a full rectangle with a chosen character, so every column is the same length. This tool supports both; Irregular round-trips your text exactly, while Complete returns it with the padding it added.
Can you show a columnar transposition example?
Take WEAREDISCOVEREDFLEEATONCE with the keyword ZEBRAS. Written into six columns it reads WEARED, ISCOVE, REDFLE, EATONC, then a short row with E. Ranking ZEBRAS alphabetically as A, B, E, R, S, Z and reading the columns in that order gives EVLN, ACDT, ESEA, ROFO, DEEC, WIREE — so the cipher text is EVLNACDTESEAROFODEECWIREE. The keyword ZEBRAS decodes it straight back.
How do you decode a columnar transposition cipher?
From the length of the cipher text and the number of columns in the keyword, work out how tall each column is — when the message does not divide evenly, the left-most columns are one letter taller. Cut the cipher text into columns in the keyword's read order, put each column back in its keyword position, and read across the rows. In this tool, choose Decode and enter the same keyword used to encode.
What does the keyword do?
The keyword does two things: its length fixes the number of columns, and the alphabetical order of its letters fixes the order the columns are read in. Only the relative ranking of the letters matters, so any two keywords with the same letter order produce the same transposition. A longer, well-mixed keyword scrambles the message more thoroughly than a short one.
What happens if the keyword has repeated letters?
Repeated letters are read left to right, in the order they appear in the keyword. So a keyword like BANANA still gives a definite column order: the three A columns are read first in their left-to-right order, then the B column, then the two N columns. This tool follows that convention, so a keyword with duplicates is perfectly usable and always decodes back correctly.
Does the cipher keep spaces and punctuation?
Yes. Because a transposition only reorders characters, this tool moves every character you enter — letters, digits, spaces, punctuation, and even emoji — so the cipher text is a rearrangement of exactly the same characters. In the keyword, however, only letters count toward the column order; spaces and other characters in the keyword are ignored.
What is the padding character for?
Padding is only used in Complete mode, where the grid is filled out to a full rectangle so every column is the same length. The padding character — X by default, but you can change it — fills the empty cells of the last row. When you decode a complete-columns message, the padding comes back at the end of the text, where it is easy to trim away.
What is double transposition?
Double transposition runs a columnar transposition twice, usually with two different keywords, so the output of the first pass becomes the input of the second. This breaks up the regular column structure that makes a single transposition easy to attack, and it was considered strong enough for serious field use for many decades. You can reproduce it here by encoding once, then encoding the result again with a second keyword.
How secure is the columnar transposition cipher?
On its own it is not secure. Because it never changes the letters, the cipher text has the same letter frequencies as the plain text, and it can be broken by anagramming — guessing the number of columns and reassembling the grid — especially for short messages or reused keywords. It becomes much stronger when combined with other steps, as in double transposition or the ADFGVX cipher. For real protection use a modern algorithm such as AES, and keep this cipher for learning and puzzles.
Is my text uploaded to a server?
No. All encoding and decoding happens entirely in your browser, so your text is never uploaded, logged, or stored. Even a share link keeps your text and keyword in the part of the URL after the hash, which browsers never send to a server, so your message stays private until you choose to share the link.

Related tools

Keep going with these handy tools

Rail Fence Cipher

Scytale Cipher

Caesar Cipher

Vigenère Cipher

Atbash Cipher

Playfair Cipher