Xerobit

Tap Code Translator: Encode and Decode Knock Code

Enter a message to convert it to tap code, or paste tap code to decode it back to plain text. This tap code translator represents each letter as a pair of taps using a 5 by 5 grid where K is merged into C. Everything runs locally in your browser and nothing is uploaded.

Result

.. ... . ..... ... . ... . ... ....

By · Published · How we build and test tools

How to use the tap code

  1. Type or paste your message into the Text or tap code field.
  2. Select Encode to convert text to tap code, or Decode to translate tap code back to text.
  3. Choose your preferred output format: Dots for visual representation or Numbers for numeric pairs.
  4. The result updates instantly as you type.

How tap code works

Tap code uses a 5 by 5 grid containing 25 letters. Because the English alphabet has 26 letters, K is merged into C. Both letters are encoded identically, and when decoding, the letter C is always returned.

The grid assigns a row number (1 to 5) and a column number (1 to 5) to each letter:

12345
1ABC/KDE
2FGHIJ
3LMNOP
4QRSTU
5VWXYZ

To encode a letter, you tap its row number, pause briefly, then tap its column number. For example, the letter H is in row 2, column 3. In dot format, this is written as .. .... In number format, it is written as the two-digit pair 23.

Worked example: encoding WATER

Let us walk through encoding the word WATER step by step using the tap code grid.

  • W: Row 5, Column 2. Dots: ..... ... Numbers: 52.
  • A: Row 1, Column 1. Dots: . .. Numbers: 11.
  • T: Row 4, Column 4. Dots: .... ..... Numbers: 44.
  • E: Row 1, Column 5. Dots: . ...... Numbers: 15.
  • R: Row 4, Column 2. Dots: .... ... Numbers: 42.

Putting it together with spaces between letters, WATER in dot format is ..... .. . . .... .... . ..... .... .., and in number format it is 52 11 44 15 42. This tap code translator puts a space between every group of dots, so the groups are read in pairs (row, then column). A slash marks a word break.

History of knock code among prisoners of war

Knock code became widely known during the Vietnam War, when American prisoners of war (POWs) used it to communicate secretly across cell walls in camps like the Hoa Lo Prison, often called the Hanoi Hilton. By tapping on pipes or walls, prisoners could pass messages without their captors understanding them.

The system was based on the Polybius square, an ancient Greek invention attributed to the scholar Polybius around 150 BC. While the original Polybius square can be adapted for various alphabets, the POWs simplified it to the standard 5 by 5 English grid with K merged into C. This made it easier to memorize under extreme stress.

A related episode is often confused with it: in 1966 Commander Jeremiah Denton blinked the word T-O-R-T-U-R-E in Morse code during a televised interview, while tap code was what prisoners used through the walls between cells. The simplicity of tap code meant that new prisoners could learn it in minutes just by listening to adjacent cells.

Tap code compared to other ciphers

Unlike a Caesar cipher which shifts letters by a fixed amount, tap code is a substitution method that converts one character into two signals. It does not encrypt the message in a mathematical sense; rather, it changes the medium of transmission from written text to auditory or physical taps.

It shares its underlying grid structure with the Playfair cipher, but Playfair encrypts pairs of letters together to increase security, whereas tap code handles one letter at a time. Tap code is also conceptually similar to Morse code, but Morse uses variable-length sequences of short and long signals, while tap code strictly uses two groups of identical taps per letter. This uniformity makes knock code slightly slower to transmit than Morse, but much easier to learn without a reference chart.

Common mistakes when using tap code

When manually encoding or decoding tap code, people frequently make a few errors. The most common is forgetting that K does not have its own position in the grid. If you try to assign K to a unique coordinate, your grid will shift and every subsequent letter will be wrong. Always treat K exactly as C.

Another mistake is losing track of the pauses. In tap code, the pause between the row taps and the column taps must be shorter than the pause between separate letters. If the timing is inconsistent, the receiver might group the taps incorrectly. For instance, the letter B (row 1, col 2) is tapped as tap... pause... tap-tap. If the middle pause is too long, it sounds like A followed by something else.

Finally, digits do not exist in the standard tap code grid, so this tool refuses to encode them: spell numbers out as words or agree on custom extensions before communicating. Punctuation is passed through unchanged.

Worked examples

ExampleInputResult
Encode HELLO as dotsText or tap code: HELLO; Direction: encode; Tap code format: dots.. ... . ..... ... . ... . ... ....
Encode SOS as numbersText or tap code: SOS; Direction: encode; Tap code format: numbers43 34 43
Decode dots to text (HELLO)Text or tap code: .. ... . ..... ... . ... . ... ....; Direction: decode; Tap code format: dotsHELLO

FAQ

What is tap code?

Tap code is a method of transmitting text by tapping out letters as pairs of numbers based on a 5 by 5 grid. It is also known as knock code because it was famously used by prisoners tapping on walls and pipes.

Why is the letter K missing from tap code?

A 5 by 5 grid only holds 25 characters. To fit the 26-letter English alphabet, K is combined with C. Whenever you need to send a K, you tap the coordinates for C, and the receiver interprets it based on context.

How do you read knock code?

Listen for two groups of taps separated by a short pause. The first group tells you the row number (1 to 5), and the second group tells you the column number (1 to 5). Look up those coordinates on the grid to find the letter. A longer pause indicates the start of a new letter.

Is tap code secure?

Tap code is not a cryptographic cipher. It does not scramble the meaning of the message; it simply translates letters into taps. Anyone who knows the 5 by 5 grid can understand it. Its value historically was hiding communication in plain sight, not mathematically securing it.

Can I use this tap code translator for numbers?

The standard tap code grid only contains letters. This tool returns an error if the input contains digits, so spell numbers out as words first. Punctuation marks are passed through unchanged.

Who invented tap code?

The underlying grid is the Polybius square, invented by the Greek historian Polybius around 150 BC. The specific application of tapping it out on prison walls was popularized by American prisoners of war during the Vietnam War in the 1960s.