Barcode Generator: Code 128, EAN-13 and UPC-A, PNG and SVG

Type some text for a Code 128 barcode, or 12 digits for an EAN-13 or 11 for a UPC-A, and the barcode appears at once with its check digit worked out.

Maintained by Hirantha Sandaruwan Lakshan. Updated 15 October 2026.

About this tool

Choose the module width, height and colours, then download a PNG or an SVG. Mistakes are reported with the exact character that is wrong. Everything is drawn in your browser from the published bar patterns.

How it works

Code 128 (ISO/IEC 15417) draws each character as a symbol 11 modules wide, with 3 bars and 3 spaces, and ends with a 13 module stop pattern. This tool uses subset B for letters, digits and punctuation (printable ASCII) and subset C for pairs of digits, which packs digits at twice the density. It looks for the shortest encoding and uses C only where that saves a symbol, which works out as 4 or more digits at the start or the end, 6 or more in the middle, and 2 or at least 4 digits when they are the whole text (not 3). The check symbol is the start value plus each symbol's value times its position (1, 2, 3 and so on), modulo 103. The Wikipedia worked example PJJ123C in code set A sums to 878, and 878 mod 103 = 54. This tool starts that text in subset B (start value 104), so its sum is 879 and its check symbol is 55; both versions decode to PJJ123C. A barcode of n symbols, counting start and check, is 11 x n + 13 modules wide plus its quiet zones.

An EAN-13 is 95 modules: a start guard 101, six left digits, a centre guard 01010, six right digits and an end guard 101, with each digit 7 modules wide. The first digit is not drawn on its own. It chooses which of two patterns (L or G) each of the six left digits uses, which is how 13 digits fit in 12 symbols. The last digit is a check digit: starting from the digit next to it, weight the digits 3, 1, 3, 1 going left, add them up, and the check digit is the amount that rounds the sum up to a multiple of 10. For 400638133393 the sum is 89, so the check digit is 1 and the full number is 4006381333931. A UPC-A is the same bars as the EAN-13 made by putting a 0 in front of its 12 digits.

Quiet zones are blank margins a scanner needs. Code 128 needs at least 10 modules on each side, an EAN-13 11 on the left and 7 on the right (GS1 Sweden size guide), and a UPC-A 9 on each side, so the whole EAN-13 or UPC-A is 113 modules wide. Module width is a whole number of pixels so every edge is sharp, and the PNG and the SVG are drawn from the same list of rectangles, so they always agree. For an EAN-13 on a consumer item GS1 gives 0.264 to 0.660 mm per module with 0.330 mm recommended, so the page shows what your pixel width means on paper at 300 dpi: 4 pixels is 0.339 mm. The same guide pairs the 0.330 mm module with bars 22.85 mm tall, about 69 modules, and the page shows how many modules tall your bars are. The tool warns about low contrast and light bars on a dark background.

A correct pattern does not guarantee a scan. The printer, label stock, size, contrast and scanner all matter, so test every barcode with a real scanner at the size and on the material you will use. Also, a drawing tool cannot give you a product number. Real EAN-13 and UPC-A numbers (GTINs) are built on a GS1 company prefix that you license from GS1 in your country. GS1 Singapore says barcodes from unauthorised sellers are not authentic, not interoperable and would not be recognised globally. Numbers typed here work for tests and internal labels, but they may clash with someone else's product.

Worked examples

Code 128 for HIRANTHA-0001

Start B, the nine characters HIRANTHA- (values 40, 41, 50, 33, 46, 52, 40, 33, 13), then Code C and the digit pairs 00 and 01. That is 13 symbols before the check symbol. The check value is (104 + 40 x 1 + 41 x 2 + ... + 1 x 12) mod 103 = 2713 mod 103 = 35. With the check symbol that is 14 symbols x 11 + 13 = 167 modules, or 187 with the two quiet zones.

EAN-13 4006381333931

The first digit 4 selects the pattern L G L L G G for the left digits 0 0 6 3 8 1, and the right digits 3 3 3 9 3 1 use the R patterns. The bars are 95 modules, 113 with quiet zones. The check digit 1 comes from the sum 89: 90 - 89 = 1, as in the Wikipedia article's Stabilo Point 88 example.

UPC-A 036000291452

Type the 11 digits 03600029145. Three times the digits in odd positions is 3 x (0 + 6 + 0 + 2 + 1 + 5) = 42, plus the even positions 3 + 0 + 0 + 9 + 4 = 16, gives 58, and 10 - 8 = 2. So the check digit is 2, which matches the UPC example on Wikipedia, and the bars equal those of the EAN-13 0036000291452.

The three barcode types compared

TypeWhat it holdsWidthQuiet zone, left / rightCheck
Code 128Printable ASCII, up to 80 characters here11 modules per symbol + 13 for the stop10 / 10 modulesCheck symbol, modulo 103
EAN-1312 digits + 1 check digit95 modules (113 with quiet zones)11 / 7 modulesCheck digit, weights 3 and 1
UPC-A11 digits + 1 check digit95 modules (113 with quiet zones)9 / 9 modulesCheck digit, weights 3 and 1

Frequently asked questions

How is the EAN-13 check digit calculated?

Take the first 12 digits. Starting from the one next to the check digit and moving left, multiply them by 3, 1, 3, 1 and so on, then add the results. The check digit is what you add to reach the next multiple of 10. For 400638133393 the sum is 89, so the check digit is 1. Type 12 digits and the tool adds it, or type 13 and it tells you if the last one is wrong.

Do I need to buy barcodes to sell a product?

Real product numbers (GTINs) are built on a GS1 company prefix, which you get by joining GS1 in your country. GS1 Singapore describes membership as the way to get a unique company prefix, and warns that barcodes from unauthorised sellers are not authentic. This tool does not allocate numbers. Ask GS1 in your country, and the shop or marketplace you sell through, what they require.

Which type should I use?

EAN-13 and UPC-A are the retail product symbols, and they only hold digits. Code 128 holds letters, digits and punctuation and is a common choice for internal labels, shipping and inventory, where you choose your own codes. If a shop or system tells you which one it needs, use that.

Why will my barcode not scan?

The usual causes are low contrast between bars and background, light bars on a dark background, bars too small for the printer, missing or cropped quiet zones, a blurry or resized image, and a glossy or curved surface. Use dark bars on a white background, a module of at least 2 or 3 pixels, and print the SVG when the size matters.

What does the invalid character message mean?

Code 128 here covers printable ASCII, from space to the tilde. Accented letters, emoji and control characters such as a line break cannot be encoded, and the message names the character, its code and its position. EAN-13 and UPC-A accept digits only; spaces and hyphens are ignored.

Should I download the PNG or the SVG?

The PNG is a fixed grid of pixels, good for screens and documents at about its own size. The SVG is a list of rectangles that stays sharp at any size, so use it for large prints and for importing into a design program. Both come from the same bar list and the same module widths.

Can it make GS1-128 or QR codes?

No. GS1-128 is Code 128 that begins with an FNC1 symbol followed by a defined data structure, and this tool does not write FNC1, so what you get is plain Code 128. For QR codes use the QR code generator on this site.

Is anything uploaded or stored?

No. The barcode is worked out and drawn inside your browser tab and nothing is sent anywhere.

Updated Oct 15, 2026