T

Text Machine

Powerful text tools, in your browser

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.

Keywords

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.

Plain text
Cipher text

Enter text above to see the result here.

ADFGX square

A

D

F

G

X

A

A
B
C
D
E

D

F
G
H
I/J
K

F

L
M
N
O
P

G

Q
R
S
T
U

X

V
W
X
Y
Z

How to use ADFGX / ADFGVX Cipher

  1. 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. 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. 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. 4

    Read the square

    Open the ADFGX square to see every letter with its row and column labels, and any keyword cells highlighted.

  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, 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?
The ADFGX cipher is a German Army field cipher from the First World War, devised by Fritz Nebel and introduced in March 1918. It is a fractionating transposition cipher: each letter is first replaced by a pair of symbols read off a Polybius square, then the whole stream of symbols is scrambled with a columnar transposition keyword. Its output uses only the letters A, D, F, G and X, which is where the name comes from.
What is the difference between ADFGX and ADFGVX?
ADFGX uses a 5×5 square of 25 cells, so I and J share a cell and only letters can be sent. ADFGVX adds a sixth label, V, for a 6×6 square of 36 cells that holds all 26 letters separately plus the digits 0 to 9, so it can encode numbers as well. ADFGVX was introduced a few months after ADFGX, in June 1918, to carry the figures that military messages needed.
Why are the letters A, D, F, G, V and X used?
Those letters were chosen because their Morse code patterns are very distinct from one another. In 1918 the cipher text was sent by radio in Morse, where noise and interference could easily turn one letter into another. Picking symbols whose Morse codes are hard to confuse meant fewer garbled messages, so the cipher was more reliable over a noisy wartime radio link.
How does the ADFGX cipher work?
It works in two stages. First, fractionation: each letter is found in the square and replaced by the label of its row followed by the label of its column, doubling the length. Second, transposition: that label stream is written in rows under a keyword, and the columns are read off in the alphabetical order of the keyword's letters. The two stages together scatter each letter's two halves across the message.
What are the two keywords for?
ADFGX uses two independent secrets. The square keyword mixes the Polybius square, deciding which pair of labels each letter becomes. The transposition keyword sets up the columns that the label stream is read off through, deciding where each half ends up. They do different jobs, and both sender and receiver must share both. In this tool the square keyword is optional and the transposition keyword can be left blank to show fractionation on its own.
Can you show a worked ADFGX example?
On the plain 5×5 square, ATTACK fractionates to AA GG GG AA AF DX, giving the stream AAGGGGAAAFDX. With the transposition key KEY, that stream is written in three columns under K, E, Y and read in alphabetical order — E, then K, then Y — to give AGAD, AGAF, GGAX. Grouped in fives, ATTACK encrypts to AGADA GAFGG AX. Changing either keyword changes the cipher text completely.
How do you decode an ADFGX message?
Reverse the two stages. From the cipher length and the transposition keyword, work out how many letters belong in each column, slice the cipher text into those columns, and put them back in their original order to rebuild the label stream. Then take the stream two labels at a time and look each row-and-column pair up in the square. In this tool, choose Decode and enter the same square, square keyword, and transposition keyword used to encode.
Who broke the ADFGVX cipher?
The French cryptanalyst Georges Painvin broke ADFGVX in June 1918 during the German spring offensive. After weeks of intense work he solved intercepted messages, including one later called the Radiogram of Victory because it revealed where the Germans planned to attack near Paris. His break is one of the best-known successes of First World War codebreaking and helped the Allies prepare for the assault.
What is fractionation in a cipher?
Fractionation is splitting each plaintext letter into two or more smaller parts — here, the row and column labels of its cell in the square — so the parts can be moved around independently. On its own, fractionation is just a substitution. Its power appears when it is combined with a transposition that separates the parts, as ADFGX does, because recovering one letter then depends on undoing the mixing of the whole message.
Does the ADFGVX square have to be random?
Historically the 1918 square was a random arrangement of the alphabet and digits, agreed in advance. This tool instead builds the square from an optional keyword, the same way a keyed Polybius or Playfair square is made: the keyword's unique characters first, then the rest in order. That is easier to remember and reproduce while giving the same kind of mixing. Leaving the square keyword blank uses the plain alphabetical square.
How secure is the ADFGX cipher?
Not secure by modern standards. Stacking fractionation and transposition defeats simple frequency analysis and made ADFGVX a strong field cipher in 1918, but it was broken even then by Georges Painvin, and modern computer-assisted methods break it readily, especially when keys are reused or plenty of cipher text is available. Its value today is educational. For real protection, use a modern algorithm such as AES and keep ADFGX 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, square, and keywords 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

Caesar Cipher

Vigenère Cipher

Atbash Cipher

Rail Fence Cipher

Playfair Cipher

Affine Cipher