Barcode Generator — Code 128 & EAN-13, PNG or SVG
Turn text or a product number into a scannable barcode — Code 128 or EAN-13 — and download it as PNG or crisp SVG.
Bar width 1–6 px; height 20–400 px.
What this tool does
It turns a piece of data into a barcode — the machine-readable pattern of bars a scanner reads. Code 128 carries any text and is the everyday workhorse for labels, inventory and shipping references; EAN-13 is the retail product code, a fixed thirteen digits with a check digit. The symbol is drawn at the size you choose and can be downloaded as a raster PNG or a print-sharp vector SVG.
The two formats
| Format | Carries | Used for |
|---|---|---|
| Code 128 | Any printable text | Labels, inventory, tracking numbers, internal codes. |
| EAN-13 | 12 digits + check | Retail products scanned at a till. |
Check digits and quiet zones
EAN-13's last digit is a checksum over the first twelve, so a scanner can detect a bad read; the tool computes it for you, or verifies it if you supply thirteen digits. Both formats also need a quiet zone — blank margin either side — or the scanner cannot tell where the symbol starts and stops. That margin is included in the generated image; leave it in place when you place the barcode on a label.
Check digit arithmetic
The EAN-13 check digit is not a secret and not a random extra digit: it is the value that makes a
weighted sum of the other twelve a multiple of ten. Numbering the digits from the left as positions
1–12, odd positions are multiplied by 1 and even positions by 3, the twelve products are added, and
the check digit is whatever brings the total up to the next multiple of ten. For
400638133393 the weighted sum is 89, so the check digit is 1 and the full code is
4006381333931.
That single digit is why a mistyped EAN-13 is refused rather than printed: the tool recomputes it when you supply twelve digits, and verifies it when you supply thirteen. It catches a wrong digit and most transpositions — but not all of them, and it cannot detect a number that is valid but wrong (the code for a different product). It is an error-detection scheme, not authentication.
Printing a barcode that actually scans
Barcode readability is physical, and three properties decide it. Module width is the width of the narrowest bar: at 2 px it is comfortable on a screen, but print at 300 dpi and the same barcode needs enough physical width that the narrow bar is at least 0.25 mm. Quiet zones are the blank margins either side — EAN-13 calls for 11 modules before the first bar and 7 after the last, Code 128 for 10 on each side — and a barcode cropped to its bars will often fail. Bar height is not decorative either: too short and the scanner's sweep crosses a gap or a scuff. At 100% magnification an EAN-13 symbol is 37.29 mm wide with 22.85 mm bars, and GS1 asks for a bar height of at least 6.35 mm or 15% of the symbol length (whichever is greater) for Code 128.
The SVG download is the one for print. It is drawn at the module width you choose but stays vector, so scaling it up does not blur the edges the way a scaled PNG does — and a blurred edge on a 1 px module is how a printable barcode becomes unreadable.
Code 128 and EAN-13 are not interchangeable
Code 128 carries any printable ASCII and any length, which is why it is used for internal references, shipping labels and asset tags; it has no check digit you supply because the encoder computes one internally for every symbol. EAN-13 is a fixed thirteen digits whose first digits identify a GS1 company prefix, and a retail till is configured to expect exactly that structure. Putting an internal SKU into EAN-13 will either fail the check digit or produce a number that belongs to another company's prefix, and putting a retail product code into Code 128 produces a symbol that a shop scanner may not recognise at all.
A barcode is not security
Anyone with a reader or a phone app can decode a barcode, so treat it as public. It is an identifier, not a secret — never put a password, a token or personal data in one. For something a human scans to visit a link or a payment, use a QR code, which carries far more data.
Frequently asked questions
Which barcode formats are supported?
Code 128 and EAN-13. Code 128 is the general-purpose format that encodes any printable text and is what most internal labels and shipping numbers use. EAN-13 is the thirteen-digit retail product code you see on shop goods, with a built-in check digit.
How much data fits in a barcode?
Code 128 is compact and handles a few dozen characters comfortably; keep it short so the bars stay thick enough for a scanner. EAN-13 is fixed at exactly 12 digits plus a check digit — it is a product identifier, not a place to store text.
What is the check digit in EAN-13?
The thirteenth digit is computed from the first twelve by a weighted sum, so a scanner can catch a mistyped or corrupted read. If you give twelve digits the tool adds the check digit; if you give thirteen it verifies the last one and tells you if it is wrong.
Can I choose PNG or SVG?
Yes. PNG is a raster image for a label or a document; SVG is vector and stays razor-sharp at any print size, which is what you want for anything that will be printed large or scaled.
Will it scan?
The bars are drawn from the standard symbol tables at a quiet-zone margin and a module width that a phone camera reads reliably on screen and in print. Barcodes are not encrypted: anyone with a reader can decode one, so do not put secrets in it.
Is my data uploaded?
No. The symbol is generated and drawn in your browser; the text you encode never leaves the page.
Go deeper
Longer explanations of the problems this tool solves:
Sources
- ISO/IEC 15417 — Code 128 barcode symbology.
- GS1 — EAN-13 specification and check-digit calculation.
Everything runs in your browser — nothing you type is uploaded.