ADFGX / ADFGVX Cipher
Encode and decode the ADFGX and ADFGVX cipher, the German Army's First World War field cipher. Each letter is first split into two label letters off a Polybius square (the fractionation step), then the whole stream is scrambled with a columnar transposition keyword. Mix the square, set the transposition key, follow the live two-stage working, and copy, download, or share the result. Everything runs in your browser.
Square key
Transposition key
The square key mixes the Polybius square that fractionates each letter; the transposition key sets the columns that scramble the result. Both sides must use the same squares and keys. Leave the transposition key blank to see the fractionation stage on its own.
Enter text above to see the result here.
ADFGX square
A
D
F
G
X
A
D
F
G
X
How to use ADFGX / ADFGVX Cipher
- 1
Choose encode or decode and a square
Pick Encode to turn plain text into ADFGX cipher text, or Decode to turn cipher text back. Choose the 5×5 ADFGX square for letters or the 6×6 ADFGVX square to also carry digits.
- 2
Set the two keywords
Optionally enter a square keyword to mix the Polybius square, and a transposition keyword to drive the columnar step. Both sides must use the same square and keys. Leave the transposition key blank to see fractionation alone.
- 3
Type or paste your text
Enter your message and it is converted as you type. The steps panel shows each letter over its two labels, then the labels filled into the keyed columns.
- 4
Read the square
Open the ADFGX square to see every letter with its row and column labels, and any keyword cells highlighted.
- 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, square, and keywords ready to go.
Understanding the ADFGX and ADFGVX Cipher
What is the ADFGX / ADFGVX cipher?
The ADFGX cipher is a field cipher invented by the German Army officer Fritz Nebel and put into service on the Western Front in March 1918, near the end of the First World War. Its extended form, ADFGVX, followed in June 1918. The cipher takes its name from the only letters that ever appear in its output — A, D, F, G, X for the original version and A, D, F, G, V, X for the extended one. Those letters were chosen deliberately: in Morse code they are very different from one another, so even a badly garbled radio transmission was unlikely to turn one into another.
ADFGX is a fractionating transposition cipher, which means it works in two stages. First it splits every letter into two symbols using a Polybius square (fractionation); then it shuffles the resulting stream of symbols with a columnar transposition driven by a keyword. Neither step alone is strong, but combining substitution with transposition spreads each letter's information across the whole message, which made ADFGVX one of the hardest field ciphers of its era.
ADFGX or ADFGVX: which square?
ADFGX uses a 5×5 square holding 25 cells. The Latin alphabet has 26 letters, so I and J share a cell, exactly as in a classic Polybius square; a decoded J therefore reads back as I. The five row and column labels are A, D, F, G and X. This is the original 1918 cipher and it can only carry letters.
ADFGVX adds a sixth label, V, to make a 6×6 square of 36 cells. That extra room lets it hold all 26 letters with nothing merged, plus the ten digits 0 to 9, so it can encode numbers — vital for sending map references, dates, and unit numbers — without spelling them out. Pick the square with the toggle above; the live reference grid relabels its rows and columns to match.
The square, the labels, and the two keywords
The heart of the cipher is the square. Reading a letter's cell gives a row label and a column label, and that pair of labels is the letter's code. This tool builds the square from an optional square keyword, just like a keyed Polybius or Playfair square: the keyword's unique letters are written in first, in order and without repeats, and the rest of the alphabet follows. The live square highlights the keyword cells so you can see the mixing. Historically the square was a random scramble; a keyword is a convenient, repeatable way to reach the same effect.
ADFGX needs a second, independent secret: the transposition keyword. After every letter has been turned into a pair of labels, the whole stream is written in rows beneath this keyword and the columns are read out in the alphabetical order of the key's letters. The two keys do different jobs — the square key decides what each letter becomes, the transposition key decides where each half ends up — and both sides must share both. Leave the transposition key blank in this tool to watch the fractionation stage by itself.
How the ADFGX cipher works
Encoding runs in two stages. Stage one, fractionation: each letter of the message is found in the square and replaced by the label of its row followed by the label of its column. A message of N letters becomes a stream of 2N label letters. Stage two, transposition: that stream is written out in rows under the transposition keyword, with as many columns as the keyword has letters, and then the columns are lifted off one at a time in the alphabetical order of the keyword's letters and joined together to form the cipher text, traditionally written in groups of five.
The transposition is what gives the cipher its strength. After fractionation, the two halves of a letter sit side by side; the columnar read-off then pulls them apart and scatters them among the halves of other letters, so that recovering any single plaintext letter requires undoing the transposition for the whole message first. The tool above shows both stages live: the fractionation panel lays each letter over its two labels, and the transposition panel shows the label stream filled into the keyed columns with their read order numbered.
A worked ADFGX example
Take the word ATTACK on the plain 5×5 square with the transposition key KEY. Fractionate each letter into its row and column labels: A is AA, T is GG, T is GG, A is AA, C is AF, and K is DX. Joined together that gives the label stream AAGGGGAAAFDX, twice as long as the original six letters.
Now transpose. The key KEY has three letters, so write the stream in three columns — AAG, GGG, AAA, FDX as four rows — under the headings K, E, Y. Read the columns in alphabetical order of the headings: E first gives A G A D, then K gives A G A F, then Y gives G G A X. Joined and grouped in fives, ATTACK encrypts to AGADA GAFGG AX. Adding a square keyword, or changing the transposition key, changes the result completely while still decrypting back to ATTACK.
Decoding an ADFGX message
Decoding reverses the two stages. From the length of the cipher text and the transposition keyword you can work out exactly how many label letters belong in each column; the cipher text is sliced back into those columns, the columns are put back in their original order, and reading across the rows rebuilds the fractionated label stream. Taking that stream two labels at a time — a row label then a column label — and looking each pair up in the square recovers the original letters. The tool does all of this for you when you choose Decode.
To decode correctly you must use the same square (the same variant and square keyword) and the same transposition keyword that were used to encode. Get any of them wrong and the columns are cut in the wrong places, so the labels pair up incorrectly and the output is garbled — which is exactly the property that made the cipher useful in the field. Because only letters live in the 5×5 square and only letters and digits in the 6×6 square, anything else in the original message was dropped during encoding and will not reappear.
History, Painvin, and security
ADFGVX is famous not only for its design but for being broken. In June 1918, as the German spring offensive pushed toward Paris, the French cryptanalyst Georges Painvin solved intercepted ADFGVX messages after weeks of exhausting work, including a message that came to be called the Radiogram of Victory because it revealed where the Germans intended to attack. His break is one of the most celebrated feats of First World War cryptanalysis and helped the Allies anticipate the assault.
By modern standards ADFGVX is not secure. Its combination of fractionation and transposition defeats simple frequency analysis, but it falls to the methods Painvin pioneered and to modern computer-assisted attacks, especially when several messages share the same keys or enough cipher text is available. Today its value is educational: it is a vivid, hands-on demonstration of how stacking substitution and transposition strengthens a cipher. For protecting real information, always use a modern, peer-reviewed algorithm such as AES, and keep ADFGX for history, puzzles, and capture-the-flag challenges.
Frequently asked questions
What is the ADFGX cipher?
What is the difference between ADFGX and ADFGVX?
Why are the letters A, D, F, G, V and X used?
How does the ADFGX cipher work?
What are the two keywords for?
Can you show a worked ADFGX example?
How do you decode an ADFGX message?
Who broke the ADFGVX cipher?
What is fractionation in a cipher?
Does the ADFGVX square have to be random?
How secure is the ADFGX cipher?
Is my text uploaded to a server?
Related tools
Keep going with these handy tools