Tool to decrypt Barcode 39. Code 39 (or Code 3 of 9 or Alpha39) is a normalized barcode system which is being replaced by Code 128.
Barcode 39 - dCode
Tag(s) : Character Encoding, Image Processing
dCode is free and its tools are a valuable help in games, maths, geocaching, puzzles and problems to solve every day!
A suggestion ? a feedback ? a bug ? an idea ? Write to dCode!
Code 39, also called Code 3 of 9 or Code 39 Barcode, is a linear barcode symbology that encodes digits, uppercase letters and seven special characters. Each character is represented by a combination of 9 elements, 3 wide and 6 narrow.
Encoding uses a character table with 43 data characters: the 26 uppercase letters, the 10 digits and 7 special characters (-, ., $, /, +, % and the space). The character * is reserved for the start/stop markers and cannot be used in the encoded data.
Each character consists of 5 black bars and 4 white spaces, for a total of 9 elements, starting with a black bar and alternating between bars and spaces. Each element can be narrow or wide, with a wide element generally measuring between 2 and 3 times the width of a narrow element. Of the 9 elements, 3 are always wide and 6 narrow, hence the name Code 3 of 9.
Successive characters are separated by a narrow white space. A Code 39 barcode begins and ends with the character *. Here is the character mapping table:
| 0 | |||▮▮|▮|| | M | ▮|▮||||▮| |
|---|---|---|---|
| 1 | ▮||▮||||▮ | N | ||||▮||▮▮ |
| 2 | ||▮▮||||▮ | O | ▮|||▮||▮| |
| 3 | ▮|▮▮||||| | P | ||▮|▮||▮| |
| 4 | |||▮▮|||▮ | Q | ||||||▮▮▮ |
| 5 | ▮||▮▮|||| | R | ▮|||||▮▮| |
| 6 | ||▮▮▮|||| | S | ||▮|||▮▮| |
| 7 | |||▮||▮|▮ | T | ||||▮|▮▮| |
| 8 | ▮||▮||▮|| | U | ▮▮||||||▮ |
| 9 | ||▮▮||▮|| | V | |▮▮|||||▮ |
| A | ▮||||▮||▮ | W | ▮▮▮|||||| |
| B | ||▮||▮||▮ | X | |▮||▮|||▮ |
| C | ▮|▮||▮||| | Y | ▮▮||▮|||| |
| D | ||||▮▮||▮ | Z | |▮▮|▮|||| |
| E | ▮|||▮▮||| | - | |▮||||▮|▮ |
| F | ||▮|▮▮||| | . | ▮▮||||▮|| |
| G | |||||▮▮|▮ | ⌴ | |▮▮|||▮|| |
| H | ▮||||▮▮|| | $ | |▮|▮|▮||| |
| I | ||▮||▮▮|| | / | |▮|▮|||▮| |
| J | ||||▮▮▮|| | + | |▮|||▮|▮| |
| K | ▮||||||▮▮ | % | |||▮|▮|▮| |
| L | ||▮||||▮▮ | * | |▮||▮|▮|| |
A narrow black bar is represented by | and a wide black bar by ▮. White spaces are represented by the separations between the bars in the table.
Example: A narrow black bar can be encoded as 1 and a wide black bar as 111. A narrow white space can be encoded as 0 and a wide white space as 000.
Example: *A* is represented by |▮||▮|▮|| ▮||||▮||▮ |▮||▮|▮||. Considering both black and white elements, the binary encoding of the three characters is 1 000 1 0 111 0 111 0 1 / 111 0 1 0 1 000 1 0 111 / 1 000 1 0 111 0 111 0 1, where / represents the space separating characters.
Decoding requires reading the bars and spaces, then using the Code 39 character mapping table.
Many smartphone apps and laser barcode scanners can facilitate this process.
Example: The message is |▮||▮|▮|| ||||▮▮||▮ ▮|▮||▮||| ▮|||▮||▮| ||||▮▮||▮ ▮|||▮▮||| |▮||▮|▮|| (alternating black bars and white spaces). The pattern |▮||▮|▮|| at the beginning and end corresponds to the character *, identifying the barcode as Code 39. Then replace each group of 9 elements with the corresponding character from the table. The decoded message is DCODE.
This example does not contain a Modulo 43 check character, which is optional in standard Code 39.
The Modulo 43 check character is optional in standard Code 39. To calculate it, assign each data character its value in the 43-character alphabet 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%, starting at 0. Do not include the start/stop characters *.
Add the values, then calculate the remainder when the sum is divided by 43 (sum modulo 43). The check character is the character whose value corresponds to this remainder in the alphabet.
Example: for DCODE, the values are D=13, C=12, O=24, D=13 and E=14. The sum is 76, and 76 modulo 43 is 33. The check character is X.
Code 39 appears as a linear barcode made of black bars and white spaces of varying widths. It can also be represented by a sequence of symbols indicating narrow and wide elements.
The barcode has variable length and begins and ends with the character *, represented by a specific pattern of bars and spaces. This pattern at both ends is a useful clue, but confirmation requires checking the groups of 9 elements against the Code 39 table.
Each Code 39 character is represented by 9 elements, 3 wide and 6 narrow. This structure also explains the alternative name of the symbology: Code 3 of 9.
dCode retains ownership of the "Barcode 39" source code. Any algorithm for the "Barcode 39" algorithm, applet or snippet or script (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, breaker, translator), or any "Barcode 39" functions (calculate, convert, solve, decrypt / encrypt, decipher / cipher, decode / encode, translate) written in any informatic language (Python, Java, PHP, C#, Javascript, Matlab, etc.) or any database download or API access for "Barcode 39" or any other element are not public (except explicit open source licence). Same with the download for offline use on PC, mobile, tablet, iPhone or Android app.
Reminder: dCode is an educational and teaching resource, accessible online for free and for everyone.
The content of the page "Barcode 39" and its results may be freely copied and reused, including for commercial purposes, provided that dCode.fr is cited as the source (Creative Commons CC-BY free distribution license).
Exporting the results is free and can be done simply by clicking on the export icons ⤓ (.csv or .txt format) or ⧉ (copy and paste).
To cite dCode.fr on another website, use the link:
In a scientific article or book, the recommended bibliographic citation is: Barcode 39 on dCode.fr [online website], retrieved on 2026-11-18,