How to make a barcode
Updated 2026-08-27 ยท about 8 minute read
Making a barcode takes about four seconds. Making one that scans reliably, and that you are actually entitled to use, takes slightly longer. This covers both.
Which barcode do you need?
Almost every practical case is one of two symbologies.
Code 128 encodes any text โ letters, digits, punctuation โ at any length. This is what shipping labels, warehouse shelf tags, asset stickers, library books, event tickets and internal order numbers use. If the barcode is for your own systems, this is almost certainly the answer. It is also dense, packing more characters into less width than the older Code 39.
EAN-13 is the thirteen-digit retail barcode on the back of virtually every product in a shop. Its American cousin UPC-A is twelve digits and is effectively a subset โ a UPC-A number with a leading zero is a valid EAN-13. Use this only for products sold through retail, and only with a number you are entitled to use, which is where most people trip up.
Both are covered by our barcode generator, which draws the symbol as you type and exports PNG or SVG.
The part nobody tells you: GS1
You cannot invent a retail barcode number.
EAN-13 and UPC numbers are built from a GS1 company prefix, issued to a specific business by GS1, the international body that administers the system. Your prefix identifies you; you assign the remaining digits to your own products; the final digit is a calculated check digit.
Generate a random thirteen-digit number and you will get a barcode that scans perfectly and means nothing โ or worse, means somebody else's product. Retailers verify that the prefix belongs to the supplier, so an invented number typically fails at onboarding. Marketplaces including Amazon check registration too.
You will also find resellers offering cheap barcode numbers from prefixes issued in the 1990s, before GS1 required licences to be per-company. They are legal to buy in most places and are rejected by a growing number of retailers. If you are selling through supermarkets, buy your own prefix.
None of this applies to Code 128. Internal codes are yours to define however you like.
How the check digit works
The thirteenth digit of an EAN-13 is not data โ it is arithmetic that lets a scanner detect a misread.
Take the first twelve digits and multiply them alternately by 1 and 3, starting with 1. Add the results. The check digit is whatever you must add to reach the next multiple of ten.
For 590123412345: (5ร1)+(9ร3)+(0ร1)+(1ร3)+(2ร1)+(3ร3)+(4ร1)+(1ร3)+(2ร1)+(3ร3)+(4ร1)+(5ร3) = 5+27+0+3+2+9+4+3+2+9+4+15 = 83. The next multiple of ten is 90, so the check digit is 7, giving 5901234123457.
The generator calculates this for you โ type twelve digits and it appends the thirteenth. Getting it wrong produces a barcode that scanners reject outright, which is the whole point.
Printing one that actually scans
Three things break barcodes in practice, and they are always the same three.
Resolution. A scanner reads the edges between bars. Scale a small bitmap up and those edges blur, and the read rate collapses. Print from SVG, which stays mathematically sharp at any size, or generate the PNG at the size you are actually printing. Never enlarge a small PNG.
Contrast. Black bars on a white background. Not grey on cream, not navy on beige. Red bars are close to invisible to the red-laser scanners still common at tills, because red light reflects off red ink almost as well as off white paper.
Size. Shrinking a barcode to fit a cramped label is the most common self-inflicted failure. A retail EAN-13 has a nominal width of about 37 mm and should not be reduced below roughly 80% of it. If it does not fit, redesign the label.
The quiet zone is not a margin
This one deserves its own section because it is the single most frequent cause of "the barcode is printed but nothing scans".
The blank space either side of a barcode is called the quiet zone, and it is part of the symbol, not decoration. A scanner uses it to work out where the code begins and ends. Crop it off, or let text or a border encroach on it, and the scanner cannot find the code at all โ even though the bars themselves are perfect.
EAN-13 needs roughly 11 modules of clear space on the left and 7 on the right; Code 128 needs at least 10 on each side. The generator's quiet-zone slider defaults to a safe value. Leave it alone unless you know why you are changing it.
Barcode or QR code?
Barcodes are one-dimensional: all the information is in the widths of the bars along a single line. That makes them fast, cheap to print and readable by simple laser scanners, but it also means they run out of room quickly. A Code 128 barcode carrying a URL becomes absurdly wide.
QR codes are two-dimensional and hold far more โ thousands of characters โ plus error correction that lets a damaged or partly covered code still decode. If you want a phone camera to open a link, use a QR code. If you want a warehouse scanner to read a part number, use a barcode. Our guide to how QR codes actually work goes into why they survive damage.
For everything else โ QR, identifiers, bulk file naming โ Pikkit has the rest of the toolkit.