Code 39 barcode specification
Example:
Code 3 of 9 is the most popular barcode for encoding alpha-numeric characters.
Key features:
- 2 different width of bar/space.
- Symbol set contains 43 characters: A-Z, 0-9, and -, ., *, $, /, +, %, SPACE.
- Each character is made up of 5 bars and 4 spaces with 3 wide bars/spaces and 6 narrow bars/spaces.
- There is a space between each character.
- The first and last character should always be the same (the * character)
- The first and last 5 black bars should always follow the pattern: narrow, narrow, wide, wide, narrow.
- The number of black bars should be divisible by 5.
- Optional checksum character modulus 43.
- Extended Code 39 uses 2 normal characters to represent one extended character, giving a 128-character symbol set.
Specification:
Symbol | Narrow/Wide Pattern | Visual Pattern | Checksum Value |
* | NWNNWNWNN | N/A | |
0 | NNNWWNWNN | 0 | |
1 | WNNWNNNNW | 1 | |
2 | NNWWNNNNW | 2 | |
3 | WNWWNNNNN | 3 | |
4 | NNNWWNNNW | 4 | |
5 | WNNWWNNNN | 5 | |
6 | NNWWWNNNN | 6 | |
7 | NNNWNNWNW | 7 | |
8 | WNNWNNWNN | 8 | |
9 | NNWWNNWNN | 9 | |
A | WNNNNWNNW | 10 | |
B | NNWNNWNNW | 11 | |
C | WNWNNWNNN | 12 | |
D | NNNNWWNNW | 13 | |
E | WNNNWWNNN | 14 | |
F | NNWNWWNNN | 15 | |
G | NNNNNWWNW | 16 | |
H | WNNNNWWNN | 17 | |
I | NNWNNWWNN | 18 | |
J | NNNNWWWNN | 19 | |
K | WNNNNNNWW | 20 | |
L | NNWNNNNWW | 21 | |
M | WNWNNNNWN | 22 | |
N | NNNNWNNWW | 23 | |
O | WNNNWNNWN | 24 | |
P | NNWNWNNWN | 25 | |
Q | NNNNNNWWW | 26 | |
R | WNNNNNWWN | 27 | |
S | NNWNNNWWN | 28 | |
T | NNNNWNWWN | 29 | |
U | WWNNNNNNW | 30 | |
V | NWWNNNNNW | 31 | |
W | WWWNNNNNN | 32 | |
X | NWNNWNNNW | 33 | |
Y | WWNNWNNNN | 34 | |
Z | NWWNWNNNN | 35 | |
– | NWNNNNWNW | 36 | |
. | WWNNNNWNN | 37 | |
SPACE | NWWNNNWNN | 38 | |
$ | NWNWNWNNN | 39 | |
/ | NWNWNNNWN | 40 | |
+ | NWNNNWNWN | 41 | |
% | NNNWNWNWN | 42 |
Checksum Calculation:
The checksum is modulus 43 sum of all the checksum values from the table above.
For example, if you are encoding the string ABCD1234 then the checksum values will be 10 + 11 + 12 + 13 + 1 + 2 + 3 + 4 = 56.
56 mod 43 = 13. So the checksum character should be D.
Extended Code 39
The Code 39 character set can be extended to a full set of ASCII characters by using 1 or 2 normal characters for each character in the extended set.
Note that a barcode reader cannot automatically determine whether a barcode is encoded normally or in the extended set.
The following table shows how to encode the full set of ASCII characters:
NUL | %U | SUB | $Z | 4 | 4 | N | N | h | +H | |||||
SOH | $A | ESC | %A | 5 | 5 | O | O | i | +I | |||||
STX | $B | FS | %B | 6 | 6 | P | P | j | +J | |||||
ETX | $C | GS | %C | 7 | 7 | Q | Q | k | +K | |||||
EOT | $D | RS | %D | 8 | 8 | R | R | l | +L | |||||
ENQ | $E | US | %E | 9 | 9 | S | S | m | +M | |||||
ACK | $F | SPACE | SPACE | : | /Z | T | T | n | +N | |||||
BEL | $G | ! | /A | ; | %F | U | U | o | +O | |||||
BS | $H | “ | /B | < | %G | V | V | p | +P | |||||
HT | $I | # | /C | = | %H | W | W | q | +Q | |||||
LF | $J | $ | /D | > | %I | X | X | r | +R | |||||
VT | $K | % | /E | ? | %J | Y | Y | s | +S | |||||
FF | $L | & | /F | ? | %V | Z | Z | t | +T | |||||
CR | $M | ‘ | /G | A | A | [ | %K | u | +U | |||||
SO | $N | ( | /H | B | B | \ | %L | v | +V | |||||
SI | $O | ) | /I | C | C | ] | %M | w | +W | |||||
DLE | $P | * | /J | D | D | ^ | %N | x | +X | |||||
DC1 | $Q | + | /K | E | E | _ | %O | y | +Y | |||||
DC2 | $R | , | /L | F | F | ‘ | %W | z | +Z | |||||
DC3 | $S | – | – | G | G | a | +A | { | %P | |||||
DC4 | $T | . | . | H | H | b | +B | | | %Q | |||||
NAK | $U | / | /O | I | I | c | +C | } | %R | |||||
SYN | $V | 0 | 0 | J | J | d | +D | ~ | %S | |||||
ETB | $W | 1 | 1 | K | K | e | +E | DEL | %T | |||||
CAN | $X | 2 | 2 | L | L | f | +F | DEL | %X | |||||
EM | $Y | 3 | 3 | M | M | g | +G | DEL | %Z |