Barcode generator (EAN-13, UPC-A, Code 128, Code 39)
Make EAN-13, EAN-8, UPC-A, Code 128, Code 39 or ITF barcodes as SVG at a true module width in mm, with check digits and quiet zones.
A clear answer. Here’s how.
EAN-13, EAN-8 and UPC-A follow the GS1 General Specifications: the check digit is the GS1 modulo-10 digit (weights 3 and 1 alternating from the rightmost data digit; the check digit takes the sum up to the next multiple of 10). A supplied check digit is verified, never silently replaced. Digits are encoded with the L, G and R patterns (EAN-13’s first digit selects the L/G parity of the left half), between 101 guards with a 01010 centre guard: 95 modules for EAN-13 and UPC-A and 67 for EAN-8. Quiet zones are 11 and 7 modules (EAN-13), 9 and 9 (UPC-A), 7 and 7 (EAN-8) and 10 on each side for Code 128, Code 39 and ITF. Code 128 uses the 107 patterns of ISO/IEC 15417 (each symbol 11 modules of 3 bars and 3 spaces, the stop pattern 13), a checksum of the start value plus each value times its position, modulo 103, and in automatic mode a shortest encoding found by dynamic programming over code sets A, B and C, including Shift (for printable ASCII, set B covers everything set A does, so set A only matters for control characters, which this tool does not take). Code 39 adds * as start and stop, a narrow gap between characters and an optional modulo-43 check character. ITF puts one digit in the bars and the next in the spaces, so an odd count gets a leading 0. Wide elements of Code 39 and ITF are 3 modules (ratio 3:1, the top of the 2.0 to 3.0 range usually quoted; sources differ on the lowest ratio allowed for very narrow modules). Some Code 39 guides also ask for a quiet zone of at least 0.1 in (2.54 mm), which matters below 0.254 mm modules. The SVG is sized in mm; the table lists every symbol and its module pattern. Colour warnings are screen-colour heuristics, not an ISO/IEC 15416 print-quality grade. Not drawn: EAN add-ons, UPC-E, GS1-128 application identifiers (FNC1), ITF-14 bearer bars, characters outside ASCII.
How this is checked
5 reference checks passed These 5 cases were run when this page was built, on 20 October 2026, and all reproduce within the stated tolerance. The same cases are part of the automated tests that run on every change to Toolmoz. Engine version 1.
See the checks and where each expected answer comes from
Case 1
- Inputs
- Barcode type ean13Data to encode 400638133393
- Expected, and what Toolmoz gave
- Check digit expected 1, Toolmoz 1Encoded data expected 4006381333931, Toolmoz 4006381333931Symbol width (modules) expected 95, Toolmoz 95Total width with quiet zones (modules) expected 113, Toolmoz 113
- Where the expected answer comes from
- Wikipedia EAN-13 worked example: weighted sum 89, next multiple of 10 is 90, check digit 1; GS1 quiet zones 11 + 95 + 7 = 113 modules
- Allowed difference
- exact
Case 2
- Inputs
- Barcode type upcaData to encode 03600029145
- Expected, and what Toolmoz gave
- Check digit expected 2, Toolmoz 2Encoded data expected 036000291452, Toolmoz 036000291452Total width with quiet zones (modules) expected 113, Toolmoz 113
- Where the expected answer comes from
- Wikipedia UPC-A worked example: odd positions 14 × 3 = 42, plus even positions 16 = 58, 10 − 8 = 2; quiet zones 9 + 95 + 9 = 113
- Allowed difference
- exact
Case 3
- Inputs
- Barcode type ean8Data to encode 9638507
- Expected, and what Toolmoz gave
- Check digit expected 4, Toolmoz 4Module pattern expected 1010001011010111101111010110111010101001110111001010001001011100101, Toolmoz 1010001011010111101111010110111010101001110111001010001001011100101
- Where the expected answer comes from
- By hand: 7×3 + 0 + 5×3 + 8 + 3×3 + 6 + 9×3 = 86, check 4; pattern 101, L codes of 9 6 3 8, 01010, R codes of 5 0 7 4, 101 from the GS1 tables
- Allowed difference
- exact
Case 4
- Inputs
- Barcode type code128Data to encode PJJ123CCode 128 code set A
- Expected, and what Toolmoz gave
- Check symbol value expected 54, Toolmoz 54Symbols expected 10, Toolmoz 10Symbol width (modules) expected 112, Toolmoz 112
- Where the expected answer comes from
- Wikipedia Code 128 worked example in code set A: 103 + 48 + 84 + 126 + 68 + 90 + 114 + 245 = 878, 878 mod 103 = 54; start, 7 data and check symbols of 11 modules plus a 13-module stop = 112
- Allowed difference
- exact
Case 5
- Inputs
- Barcode type code39Data to encode CODE39Code 39 check character mod43
- Expected, and what Toolmoz gave
- Check character expected W, Toolmoz WSymbol width (modules) expected 143, Toolmoz 143
- Where the expected answer comes from
- By hand: C 12 + O 24 + D 13 + E 14 + 3 + 9 = 75, 75 mod 43 = 32 = W; *CODE39W* is 9 characters of 15 modules plus 8 one-module gaps = 143
- Allowed difference
- exact
What this shows: the engine reproduces independently worked values for these cases. It does not prove every possible input is right. To test an answer you were given, see how to check a number; to see what is and is not checked across Toolmoz, see the accuracy ledger.
See a worked example
Worked example
A fixed demonstration, separate from the values you enter above.
- Barcode type
- EAN-13 (retail, 13 digits)
- Data to encode
- 400638133393
- Module width (narrowest bar) in mm
- 0.33
- Bar height in mm
- 22.85
- Text under the bars
- Show
- Bar colour
- #000000
- Background colour
- #ffffff
Example result
| # | Symbol | Value | Bar and space widths | Modules (1 = bar) |
|---|---|---|---|---|
| 1 | Start guard | 101 | ||
| 2 | 0 | L code | 0001101 | |
| 3 | 0 | G code | 0100111 | |
| 4 | 6 | L code | 0101111 | |
| 5 | 3 | L code | 0111101 |
Print at 100% scale, keep the quiet zones clear and test with the scanner that will read it: a code that scans on screen can still fail in print.