Barcode Generator
Last reviewed: 20 November 2026. Reviewed every 180 days; next review due 19 May 2027.
How to use the barcode generator
This barcode generator draws three barcode formats right in your browser: EAN-13 for retail products sold worldwide, UPC-A for retail products in the United States and Canada, and Code 128 for labels, stock codes, and shipping marks that mix letters and digits. Nothing you type is uploaded anywhere. The bars are drawn on your device, and the PNG download comes straight from your browser.
- Pick a format. Choose EAN-13, UPC-A, or Code 128 at the top of the tool. Each card says what the format is for. If you are labeling a product for a shop, the shop or your GS1 membership decides the format for you: EAN-13 outside North America, UPC-A inside it.
- Type the number or text. For EAN-13, enter 12 digits and the tool adds the check digit for you, or enter all 13 digits to check a number you already have. For UPC-A, enter 11 digits or all 12. For Code 128, type letters, digits, and punctuation, up to 50 characters. Spaces and hyphens in an EAN-13 or UPC-A number are ignored, so you can paste a number written as 5901 2341 2345.
- Read the result. The barcode appears as soon as the input is valid. Under it you get the full encoded value, the check digit, the total number of modules, the number of bars, and the quiet zones on each side. The module pattern line shows every bar and space width in order, so you can check the symbol against the published tables.
- Download the PNG. Use the Download PNG button to save the barcode with its human-readable text underneath. Print it at a size where the narrowest bar stays sharp, and test-scan the print before you print a batch.
If the tool shows a red error instead of a barcode, read the message: it names the exact problem. The most common ones are a wrong number of digits, a letter inside an EAN-13 or UPC-A number, and a check digit that does not match the digits before it. A mismatched check digit almost always means one digit was mistyped, and the message tells you what the check digit should be.
The Load example button fills in a known-good value for the format you picked: 590123412345 for EAN-13, 03600029145 for UPC-A, and HELLO-123 for Code 128. Use it to see a working barcode before you type your own value.
How it works
A linear barcode is a row of bars and spaces whose widths spell out a number or a piece of text. A scanner reads the widths, not the picture, so the exact sequence of widths is the whole content of the symbol. This tool builds that sequence from the published encoding tables for each format, then draws it on a canvas with the quiet zones and the human-readable text the standards require.
The check digit in EAN-13 and UPC-A
The last digit of every EAN-13 and UPC-A number is a check digit. GS1 describes it as the final digit of all fixed-length numeric GS1 identification keys, and its job is to protect the integrity of the key: it catches typing mistakes before a wrong number reaches a shelf or a till. The check digit is calculated from the digits before it with the GS1 modulo-10 method, which works the same way for every GTIN length. Count from the right of the number without its check digit, multiply the digits by 3 and 1 in turn, add the results, and the check digit is whatever brings the total up to the next multiple of 10. If the total already ends in 0, the check digit is 0.
Here is the method worked through on the 12 digits 400638133393, the number printed on a Stabilo Point 88 pen. Counting from the left, the weights are 1, 3, 1, 3, and so on, because a 12-digit body has an even length:
| Digit | 4 | 0 | 0 | 6 | 3 | 8 | 1 | 3 | 3 | 3 | 9 | 3 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Weight | 1 | 3 | 1 | 3 | 1 | 3 | 1 | 3 | 1 | 3 | 1 | 3 |
| Product | 4 | 0 | 0 | 18 | 3 | 24 | 1 | 9 | 3 | 9 | 9 | 9 |
The products add up to 89. The next multiple of 10 is 90, so the check digit is 90 minus 89, which is 1. The full EAN-13 number is 4006381333931. GS1's own published worked example follows the same steps on the 12 digits 629104150021: the weighted sum is 57, the next multiple of 10 is 60, and the check digit is 3, giving 6291041500213.
For UPC-A the same rule is often written from the left, because an 11-digit body has an odd length. Take 03600029145. Add the digits in the odd positions, first, third, fifth, seventh, ninth, and eleventh: 0 plus 6 plus 0 plus 2 plus 1 plus 5 equals 14. Multiply by 3 to get 42. Add the digits in the even positions: 3 plus 0 plus 0 plus 9 plus 4 equals 16, giving 58 in total. The remainder of 58 divided by 10 is 8, and 10 minus 8 is 2, so the check digit is 2 and the full number is 036000291452. Counted from the right, the two wordings are the same rule: the digit next to the check digit always gets the weight 3.
A check digit is error detection, not error correction. It catches every single mistyped digit, because changing one digit always changes the weighted sum by an amount that is not a multiple of 10. It catches most swaps of two neighboring digits, but not all: if the two swapped digits differ by exactly 5, the weighted sum does not change, so the swap passes unnoticed. That is why EAN-13 catches about 90 percent of transpositions and UPC-A about 89 percent. A valid check digit also says nothing about whether a number is registered to a real product. Any string of digits can be given a correct check digit by arithmetic; only a GS1 license makes the number yours.
How EAN-13 packs 13 digits into 12 bar patterns
An EAN-13 symbol is exactly 95 modules wide, where a module is the narrowest bar or space. The layout is a start guard of 3 modules, six left-hand digits of 7 modules each, a center guard of 5 modules, six right-hand digits of 7 modules each, and an end guard of 3 modules: 3 plus 42 plus 5 plus 42 plus 3 equals 95. The start and end guards are the pattern 101, bar, space, bar, and the center guard is 01010. Every digit is drawn as two bars and two spaces, each 1 to 4 modules wide, and the whole symbol has 30 bars.
Only 12 of the 13 digits get a bar pattern. The first digit is encoded indirectly, by the choice of pattern used for each of the six left-hand digits. Each left-hand digit can be drawn in one of two sets: L, with an odd number of dark modules, or G, with an even number. The right-hand digits always use set R, which is the exact complement of L: every bar becomes a space and every space becomes a bar. G is the R pattern read in reverse. For the digit 0, L is 0001101, G is 0100111, and R is 1110010.
There are ten possible L and G combinations across the six left-hand positions, one for each possible first digit. A first digit of 0 uses LLLLLL, which is why a UPC-A code is identical to an EAN-13 code with a leading zero. A first digit of 5 uses LGGLLG. So the number 5901234123457 is drawn with the left-hand digits 901234 in the sets L, G, G, L, L, G, and a scanner recovers the leading 5 from that pattern alone. The first group always starts with an L pattern and the second group always starts with an R pattern, which is part of how a scanner can tell which way up the symbol is when it is read from either direction.
The first two or three digits of an EAN-13 number are the GS1 prefix. It identifies the GS1 member organization that issued the number, not necessarily the country where the product was made. The prefixes 978 and 979 are reserved for books, so an ISBN-13 is an EAN-13 number for a book, and 977 marks serial publications. Prefixes 020 to 029 are set aside for retailer internal use, for example for products weighed and packed in the store.
How Code 128 works
Code 128 is a high-density linear symbology defined in ISO/IEC 15417 and developed by the Computer Identics Corporation in 1981. It has 108 symbols: 103 data symbols, 3 start symbols, and 2 stop symbols. Each symbol is three bars and three spaces of varying widths, 1 to 4 modules each, adding up to exactly 11 modules. The stop symbol is special: it is followed by a final 2-module bar, making a 13-module stop pattern that a scanner can recognize from either direction.
Code 128 has three code sets. Set A covers ASCII characters 0 to 95, including control codes. Set B covers ASCII characters 32 to 127, which is the printable range plus delete: digits, upper and lower case letters, and punctuation. Set C encodes pairs of digits, 00 to 99, one symbol per pair, which makes it compact for long numbers. This tool encodes in set B only, one symbol per character, which covers the text people usually put on a label. Set C is only worth the switch for runs of at least four digits at the start or end of the text, or six digits in the middle, because entering and leaving the set costs a symbol each way.
Every Code 128 symbol ends with a checksum symbol, calculated as a weighted sum modulo 103. Take the start symbol value, add each data symbol value multiplied by its 1-based position, and take the remainder after dividing by 103. For the text "Hi" in set B: the start symbol B has the value 104, H has the value 40, and i has the value 73. The sum is 104 plus 40 times 1 plus 73 times 2, which is 104 plus 40 plus 146, equal to 290. Dividing 290 by 103 leaves a remainder of 84, so the checksum symbol is 84. The full symbol sequence is start B, H, i, checksum 84, stop, and the symbol is 57 modules wide: four 11-module symbols plus the 13-module stop pattern.
Code 128 is the base for GS1-128, formerly known as UCC/EAN-128, which is used widely in shipping and logistics to carry product, date, and batch information on cartons and pallets. GS1-128 adds application identifiers in front of the data, which this tool does not add: the barcodes here are plain Code 128.
Quiet zones and guard bars
Every barcode needs blank space on both sides, called the quiet zone, so the scanner can find the edges of the symbol. The minimum quiet zone for EAN-13 is 11 modules on the left and 7 modules on the right, which makes the full width 113 modules including the quiet zones. UPC-A needs at least 9 modules on each side. Code 128 needs at least 10 modules on each side. This tool draws the minimum quiet zone for each format, and the PNG includes it, so you should not crop the image tight to the bars. Text, borders, or a neighboring label inside the quiet zone can stop a scanner from reading the code at all.
On EAN-13 and UPC-A, the guard bars and the first and last digits are drawn slightly longer than the other bars. That extended length is part of the standard: it gives the scanner extra timing marks and it gives the symbol its familiar notched outline. The human-readable digits sit underneath the bars. On EAN-13 the first digit is printed to the left of the start guard, outside the symbol, because it has no bar pattern of its own. On UPC-A the first and last digits sit outside the guards the same way. On Code 128 the whole text is centered under the bars.
What your result means
The result panel under the barcode explains the symbol in numbers, so you can check it rather than taking it on trust.
Encoded value is the full content of the barcode. For EAN-13 and UPC-A it is the complete number including the check digit, even if you typed only the digits before it. For Code 128 it is your text exactly as typed. If the encoded value is not what you expected, check the input: leading zeros matter, and for EAN-13 and UPC-A the tool keeps them, because a number stored as text in a spreadsheet often loses them.
Check digit is the final digit of an EAN-13 or UPC-A number, with the weighted sum it came from. If you typed the full number, the tool verifies the check digit instead of computing it, and says so in the notes. For Code 128 the matching field is the checksum symbol, a value from 0 to 102 with the weighted sum behind it. A scanner recomputes this value on every read, which is why a damaged Code 128 symbol is rejected rather than misread.
Total modules is the width of the symbol in modules, not counting the quiet zones. EAN-13 and UPC-A are always 95 modules. Code 128 grows with the text: 11 modules per character plus 11 for the start symbol, 11 for the checksum symbol, and 13 for the stop pattern, which is 11 times the character count plus 35. A 10-character Code 128 label is 145 modules wide, and a 50-character one is 585 modules, which is why long Code 128 symbols need a wide label or a 2D code instead.
Bars counts the black bars in the symbol. EAN-13 and UPC-A always have 30: 24 from the twelve digits plus 6 from the three guard patterns. Code 128 has three bars per symbol plus one extra bar in the stop pattern. Quiet zones states the blank margin on each side in modules. Width with quiet zones is the full footprint you need on the label.
Module pattern lists every bar and space width in order, starting with a bar. For EAN-13 and UPC-A the widths are all 1 to 4 modules, and the list always starts 1-1-1 for the start guard and ends 1-1-1 for the end guard. If you ever need to prove a symbol is correct, this list is the symbol: any barcode drawn from the same widths reads the same.
Barcode formats explained
The three formats on this page cover most everyday barcode jobs, but they are not interchangeable. The table below compares them, and the paragraphs after it explain when to reach for each one.
| Feature | EAN-13 | UPC-A | Code 128 |
|---|---|---|---|
| Characters | 13 digits | 12 digits | Letters, digits, punctuation |
| Length | Fixed, 13 digits | Fixed, 12 digits | Variable, up to 50 characters here |
| Check character | Modulo-10 check digit | Modulo-10 check digit | Modulo-103 checksum symbol |
| Symbol width | 95 modules | 95 modules | 11 modules per character plus 35 |
| Bars | 30 | 30 | 3 per symbol plus 1 in the stop pattern |
| Quiet zones | 11 modules left, 7 right | 9 modules each side | 10 modules each side |
| Main use | Retail products worldwide | Retail products in the US and Canada | Labels, stock, shipping, asset tags |
| Number source | GS1 member organization | GS1 US | Your own text, no license needed |
EAN-13 is the retail barcode used in most of the world. Its 13 digits form a GTIN-13: a GS1 company prefix, an item reference chosen by the company, and the check digit. The number identifies a trade item, one product in one pack size, and the same product in a different pack size gets a different number. EAN-13 is an extension of UPC-A with an extra leading digit, which is why every UPC-A number is also an EAN-13 number with a 0 in front, and the check digit does not change.
UPC-A is the retail barcode of the United States and Canada. It was adopted by the US grocery industry in 1973, with the symbol designed by George Laurer at IBM. The first product ever scanned at a retail checkout was a pack of Wrigley's Juicy Fruit gum at a Marsh supermarket in Troy, Ohio, on 26 June 1974, ringing up 67 cents. A UPC-A number has a number system digit first, then a manufacturer code, then a product code, then the check digit. At nominal size the narrowest bar is 0.33 millimeters wide, the symbol is 25.9 millimeters tall, and the symbol may be printed from 80 percent to 200 percent of nominal size.
Code 128 is the format to use when the content is not a retail product number. It encodes any printable text, so it suits stock codes, serial numbers, order numbers, shelf labels, and asset tags. Because it is variable length, it grows with the text, and a long symbol can become too wide for the label. When the text is long or the label is small, a 2D code such as a QR code carries the same text in far less space: see our QR code generator for that. Code 128 also has smaller relatives for special cases: UPC-E compresses certain UPC-A numbers into 6 digits for small packs, and EAN-8 is the 8-digit version of EAN-13 for small products, but neither is a shortened version of a longer number, and each needs its own number assignment.
One warning applies to all three formats: a barcode generator can draw a symbol for any number, but it cannot make the number legitimate. Retail numbers come from GS1. A number you invent, even with a correct check digit, either belongs to someone else or to nobody, and a retailer will reject it. Code 128 text is different: it is your own label content, and no license is needed for it.
Common mistakes to avoid
Typing the check digit in the wrong place. If you already have a full 13-digit EAN-13 number, enter all 13 digits and let the tool verify it. If you enter the 13 digits as though the check digit were still missing, the tool reads the last digit as data and computes a different check digit, giving you a 14-digit result that is not your number.
Losing leading zeros. Spreadsheet programs drop leading zeros from numbers. A UPC-A number starting with 0, such as 036000291452, becomes 36000291452 in a spreadsheet, which is 11 digits and fails the length check. Store barcode numbers as text, and re-add any zero that was dropped before you generate the symbol.
Inventing a retail number. A correct check digit does not make a number yours. Retailers check numbers against GS1 records, and a made-up number will be rejected at listing or at the till. Get a GS1 company prefix first, then build item numbers inside it.
Cropping the quiet zones. The blank margins are part of the symbol. Cropping the PNG tight to the bars, or letting text or a border touch the symbol, is the most common reason a printed barcode will not scan. Keep the full quiet zone clear on both sides.
Printing too small or too faint. Bars must stay sharp and dark on a light background. Printing a 95-module symbol in a space meant for a much shorter one squeezes the narrow bars below what a scanner can resolve, and low-contrast printing, colored bars on a colored background, or a glossy label that reflects the scanner light all cause failed reads. Print at a size where the narrowest bar is clearly visible, in black on white where possible, and test-scan the first print.
Stretching the image. Resizing a barcode image unevenly, wider in one direction than the other, changes the relative widths of the bars and spaces, which is the data itself. If you resize the PNG, scale it evenly and keep the proportions locked. Do not stretch a barcode to fill a space.
Using the wrong format for the job. A Code 128 symbol carrying a 12-digit number is not a UPC-A code, and a shop till expecting UPC-A will not read it as one. A retail product needs the retail format for its market. Code 128 is for labels and internal tracking, not for the checkout.
Putting non-ASCII text in Code 128. Code 128 set B covers printable ASCII only, from space to tilde. Accented letters, symbols from other scripts, and emoji cannot be encoded in set B. If your text needs those characters, use a QR code instead.
Frequently asked questions
How do I calculate an EAN-13 check digit?
Take the 12 digits without the check digit, multiply them by 1 and 3 in turn from the left, add the results, and subtract the total from the next multiple of 10. For 400638133393 the weighted sum is 89, the next multiple of 10 is 90, and the check digit is 1, giving 4006381333931. If the sum already ends in 0, the check digit is 0. This generator does the calculation for you when you enter 12 digits.
What is the difference between EAN-13 and UPC-A?
EAN-13 has 13 digits and is used for retail products worldwide, while UPC-A has 12 digits and is used in the United States and Canada. The symbols share the same 95-module layout, and every UPC-A number is an EAN-13 number with a leading 0, with the same check digit. The leading digit of an EAN-13 number is encoded by the parity pattern of the left half, not by bars of its own.
Can I use a barcode from this generator on a product I sell?
Only if the number is yours. Retail numbers come from GS1: you license a company prefix and build item numbers inside it. This generator draws the symbol correctly and computes a valid check digit, but a valid check digit does not prove the number is registered to you, and a retailer will reject a number that is not yours. Code 128 labels are different, because the text is your own content and needs no license.
What characters can Code 128 encode?
Code 128 has three code sets. Set A covers ASCII 0 to 95 including control codes, set B covers printable ASCII from space to tilde including lower case letters, and set C encodes digit pairs for compact numbers. This tool encodes in set B only, up to 50 characters, which covers digits, letters, and punctuation. Accented letters and other non-ASCII characters cannot be encoded in set B.
Why does my barcode have blank space on each side?
That blank space is the quiet zone, and it is part of the symbol. Scanners need it to find the edges of the barcode. The minimum quiet zone is 11 modules on the left and 7 on the right for EAN-13, 9 modules on each side for UPC-A, and 10 modules on each side for Code 128. Cropping it off or letting text touch the bars is the most common reason a printed barcode will not scan.
How big should I print a barcode?
At nominal size a UPC-A symbol has a narrowest bar of 0.33 millimeters and a height of 25.9 millimeters, and it may be printed from 80 percent to 200 percent of that size. In practice, print as large as the label allows, keep the bars black on a white background, scale the image evenly without stretching, and test-scan the first print with the scanner that will read it. A barcode that scans on screen can still fail on paper if the print is faint or the bars bleed together.
What does the check digit catch?
The check digit catches every single mistyped digit in an EAN-13 or UPC-A number, and about 9 in 10 swaps of two neighboring digits. The swaps it misses are the ones where the two digits differ by exactly 5, such as 0 and 5 or 3 and 8, because those leave the weighted sum unchanged. It is error detection, not error correction: it tells you a number is wrong, not which digit is wrong, and it cannot confirm that a product is genuine.
Can a barcode be scanned upside down?
Yes. EAN-13 and UPC-A are designed to be read in either direction: the guard patterns are symmetric, the left half starts with an odd-parity pattern and the right half with an even-parity pattern, and the check digit confirms the reading. Code 128 is also bidirectional, because its stop pattern reads differently from the front and the back. The scanner still needs a clean print, a full quiet zone, and a scan line that crosses the whole symbol.
Sources
- GS1: Check digit calculator — the check digit is the last digit of all fixed-length numeric GS1 identification keys and ensures the integrity of the key. Accessed 20 November 2026.
- GS1: EAN/UPC barcodes — the GS1 standards page for EAN/UPC barcodes, pointing to the GS1 General Specifications. Accessed 20 November 2026.
- Wikipedia: International Article Number — the EAN-13 structure, the L, G, and R encoding tables, the left-half parity table, the 95-module layout, the worked check digit example for 4006381333931, the GS1 prefix rules, and the 90 percent transposition detection figure. Accessed 20 November 2026.
- Wikipedia: Universal Product Code — the UPC-A structure and 30 bars, the check digit equation and the worked example for 036000291452, the 0.33 millimeter nominal x-dimension, the 25.9 millimeter height, the 80 to 200 percent magnification range, the 9-module quiet zones, the 1973 adoption and the first scan on 26 June 1974, and the 89 percent transposition detection figure. Accessed 20 November 2026.
- Wikipedia: Code 128 — the full Code 128 width table used to build the encoder, the 108 symbols, the 11-module symbols and the 13-module stop pattern, the modulo-103 checksum, code sets A, B, and C, the 10-module quiet zones, ISO/IEC 15417, and the 1981 origin at Computer Identics Corporation. Accessed 20 November 2026.
- NanToo: EAN-13 Barcode Math — the EAN-13 quiet zones of 11 modules left and 7 right, the 95-module symbol and 113 modules with minimum quiet zones, citing GS1 General Specifications Release 26.0, sections 5.2.3.4-5 and 5.2.6.3, plus the worked check digit example for 4901234567894. Published 17 October 2026. Accessed 20 November 2026.