Skip to main content
ponderloop

Barcode Generator (Code 128, EAN-13, UPC-A, EAN-8, Code 39)

Choose a barcode type, type the number or text and the barcode appears at once, with the check digit worked out for you and nothing uploaded. The example 4006381333931 is the 12 digits 400638133393 plus the check digit 1: an EAN-13 of 95 modules with quiet zones of 11 and 7 modules, drawn 4 pixels per module as 452 × 174 px. Download it as a PNG at your size and DPI, or as a scalable SVG, or copy the SVG. The encoders are written for this site to ISO/IEC 15417 (Code 128), the GS1 General Specifications (EAN and UPC) and ISO/IEC 16388 (Code 39).

Updated Runs in your browser: nothing you enter is uploadedHow this tool works

What should the barcode say?

12 digits plus a check digit. Retail products worldwide (ISBN books start 978 or 979).

The module is the narrowest bar. DPI sets the printed size shown below and is saved in the PNG.

Your barcode

4006381333931

Type
EAN-13
Number
4006381333931
Check digit
1 (verified, GS1 modulo 10)
Left-hand digits use
L G L L G G (odd/even parity)
Width
95 modules plus 11 and 7 quiet zone
Image
452 × 174 px, 4 px per module
Printed at 300 DPI
1.51 in × 0.58 in (38.27 mm × 14.73 mm), module 0.34 mm

Made on your device: nothing you type is uploaded, saved or put in the address of this page.

The five barcode types

What each type holds and how wide it is for the examples used here. Widths count modules (the narrowest bar); the quiet zone is the empty margin the standard asks for on each side.
TypeHoldsCheckExampleWidthQuiet zone (left, right)
Code 128ASCII text, digits packed in pairsModulo 103 symbolPJJ123C112 modules10 and 10 modules
EAN-1313 digitsGS1 digit400638133393195 modules11 and 7 modules
UPC-A12 digitsGS1 digit03600029145295 modules9 and 9 modules
EAN-88 digitsGS1 digit7351353767 modules7 and 7 modules
Code 390-9, A-Z, space and - . $ / + %Optional modulo 43CODE39127 modules10 and 10 modules

How the check digit of 4006381333931 is worked out

Working from the right, the digits are multiplied by 3, 1, 3, 1 and so on and added: the sum is 89. The check digit is what makes the total a multiple of 10: (10 − 89 mod 10) mod 10 = 1. The same rule gives the last digit of EAN-8, UPC-A and EAN-13.
PositionDigitWeightProduct
1414
2030
3010
46318
5313
68324
7111
8339
9313
10339
11919
12339

EAN-13 left half: which digits use odd or even parity

EAN-13 has 13 digits but only 12 are drawn as digit codes: the first digit is hidden in which of the six left-hand digits use the L (odd parity) or G (even parity) codes. UPC-A is the same symbol with a first digit of 0 (all L).
First digitParity of the six left-hand digits
0L L L L L L
1L L G L G G
2L L G G L G
3L L G G G L
4L G L L G G
5L G G L L G
6L G G G L L
7L G L G L G
8L G L G G L
9L G G L G L

Code 128 character sets

A single Code 128 symbol can switch between three sets. The tool picks the sequence with the fewest symbols: for example PJJ123C needs 8 symbols plus the check and stop in set A, while 12345678 is 4 pairs in set C after the start character.
SetCharactersStart valueBest for
ADigits, capitals, control codes (ASCII 0-95)103Capital letters and control characters
BDigits, capitals, lowercase, punctuation (ASCII 32-127)104General text
CPairs of digits 00 to 99105Long numbers, at half the width

Code 39 characters in value order

The 43 characters in the order used for the optional check character: add the values of the data characters and take the remainder after dividing by 43. CODE39 adds up to the check character W, giving CODE39W.
ValuesCharacters
0 to 90 1 2 3 4 5 6 7 8 9
10 to 19A B C D E F G H I J
20 to 29K L M N O P Q R S T
30 to 39U V W X Y Z - . space $
40 to 42/ + %

Sizes the tool warns about

GS1 sizes retail EAN and UPC symbols from 80% to 200% of a nominal module of 0.33 mm. The tool shows one module in millimetres at your DPI and warns outside that range.
Module widthDPIOne moduleWithin GS1 range?
2 px3000.169 mmNo, too small
3 px3000.254 mmNo, too small
4 px3000.339 mmYes
4 px6000.169 mmNo, too small
8 px3000.677 mmNo, too large

How to make a barcode

  1. Choose the type and enter the data. Pick Code 128, EAN-13, UPC-A, EAN-8 or Code 39 and type the number or text. For EAN and UPC you can leave the check digit off (the tool adds it) or include it (the tool checks it and shows the correct digit if it is wrong). Spaces and hyphens in the number are ignored.
  2. Set the module width, height and DPI. Module width is the number of pixels in the narrowest bar. Bar height is in pixels. DPI decides the printed size shown under the barcode and is saved in the PNG. For retail EAN or UPC, aim for a module of about 0.33 mm: 4 pixels at 300 DPI is 0.34 mm.
  3. Download or copy it. Download PNG for documents and labels, Download SVG for print and anything that must stay sharp at any size, or copy the SVG markup into a design file. Print a test sheet and scan it before you print many.

Frequently asked questions

Is this barcode generator free, and is my data sent anywhere?
It is free and runs entirely in your browser. The barcode is calculated on your device by code that ships with this page, so the numbers and text you type are never uploaded or saved.
Which barcode type should I use?
Use EAN-13 (or UPC-A in the US and Canada) for products sold in shops: the number must be a registered GS1 number. Use Code 128 for shipping labels, inventory, tickets and any text: it is compact and holds all of ASCII. Use Code 39 when a system or standard asks for it, as in badges, some automotive and government uses. EAN-8 is for packages too small for an EAN-13.
What is the check digit and how is it calculated?
The check digit catches a mistyped or misread digit. For EAN-13, UPC-A and EAN-8, the digits are weighted 3, 1, 3, 1 from the right, added, and the check digit brings the total up to a multiple of 10. For 400638133393 the sum is 89, so the check digit is 1 and the number is 4006381333931. Code 128 has a check symbol (a weighted sum modulo 103, added automatically), and Code 39's check character is optional.
What happens if the check digit I typed is wrong?
The tool does not draw a barcode with a wrong check digit. It shows the correct one instead: Check digit mismatch: the last digit is 2 but the correct check digit for 400638133393 is 1, which makes 4006381333931.
Do I get a real, registered product barcode from this?
No. This tool draws the symbol for a number you supply. The company prefix inside an EAN or UPC number is licensed by GS1, and shops and marketplaces check that the number belongs to you. Get your numbers from GS1 in your country; then use this tool to draw them.
What is a quiet zone, and why does it matter?
The quiet zone is the empty margin on each side that tells a scanner where the barcode starts and ends. This tool always includes it: 11 and 7 modules for EAN-13, 9 and 9 modules for UPC-A, 7 and 7 modules for EAN-8 and 10 modules for Code 128 and Code 39. If you place the image on a coloured background or crop it, keep that margin clear.
How does Code 128 choose between its code sets?
Code 128 has three character sets: A (capitals and control codes), B (upper and lowercase) and C (pairs of digits). The tool finds the sequence with the fewest symbol characters, switching sets where it saves space and using a single-character shift for one control code in lowercase text. A run of digits is packed in pairs in set C, half the width. For PJJ123C the check symbol is 54.
What module width, height and DPI should I choose?
The module width is how many pixels the thinnest bar is; the DPI says how big a pixel is on paper. Their ratio is the physical module size. Retail EAN and UPC use about 0.33 mm, within 0.264 to 0.66 mm. For other barcodes a module of 0.25 mm or more is typical for office and label printers. Bars should be tall: a height of at least 15% of the barcode width is typical for Code 128 and Code 39.
Should I download PNG or SVG?
PNG is a grid of pixels at exactly the size you chose, with the DPI saved in the file, which suits documents and label software. SVG is vector, so it stays sharp at any size and is the better choice for print; its width and height are set in inches from your DPI. Copy SVG puts the markup on the clipboard to paste into a design tool or web page.
Are the encoders correct?
Each encoder is written from the standards: Code 128 with the 107 bar/space patterns, automatic code set selection and the modulo 103 check symbol; EAN-13, UPC-A and EAN-8 with the L, G and R digit codes, the parity table and GS1 check digit; Code 39 with its 43 patterns and the optional modulo 43 check. The tests check the pattern tables against the ZXing reference decoder data, the GS1 example 4006381333931, the Code 128 worked example PJJ123C, and read generated symbols back with an independent decoder. Code 128 FNC characters (GS1-128), add-on digits (EAN-2 and EAN-5) and UPC-E are not supported.

How it works

Each type becomes a string of modules, 1 for a bar and 0 for a space. For EAN-13 the number is checked (or its 13th digit computed) and drawn as a 3-module start guard, six left digits of 7 modules each, a 5-module centre guard, six right digits and an end guard: 95 modules. The first digit selects which left digits use the odd (L) or even (G) set. UPC-A is drawn as an EAN-13 with a leading 0, and EAN-8 as four left and four right digits (67 modules). Code 128 starts with a start character that names the first set, then data symbols of 11 modules each, the check symbol (the start value plus each value times its position, modulo 103), and the 13-module stop pattern 2331112. The set sequence is the shortest one, found by dynamic programming over the position and the current set. Code 39 draws each character as nine elements (three wide, each wide element 3 modules), separated by a one-module space, with * at both ends. The drawing is laid out in whole pixels per module, so edges stay sharp: quiet zones left and right, a small margin above and below, bars of the height you chose (EAN and UPC guards run longer) and the human-readable text under them. SVG and PNG come from the same layout. The PNG gets a pHYs chunk with your DPI. Everything runs in your browser; nothing you enter is sent anywhere.

Sources

All toolsHome & DIY calculators