Skip to content

Free Barcode Generator — EAN-13, UPC-A & Code 128

Generate EAN-13, UPC-A, Code 128, Code 39 and 11 more barcode types as SVG or print-ready PNG. Type 12 digits and the check digit is filled in; get one wrong and we name the digit it should be.

No Tracking Runs in Browser Free
Barcodes are drawn in your browser. Nothing is uploaded.

Appearance & print size

Batch generate (one value per line)

Rows that fail validation are listed with their reason in skipped.txt inside the ZIP.

A barcode that scans at retail needs a GS1-issued company prefix. This tool draws the graphic; it does not assign numbers. Internal labels need no registration.

Every number on this page was computed and then checked twice. The check digits are verified against real published barcodes — the ISBN-13 of a printed textbook, a Coca-Cola 330 ml can, and the reference examples for UPC-A and EAN-8 — and independently against the encoder's own calculation. The Code 128 module counts come from a formula that was tested sample by sample against the rendered output, which is also how the odd-digit switch penalty was found. The claim that GS1 prefixes do not indicate country of origin is GS1's own published position. — Go Tools Engineering · Sep 24, 2026

Written and reviewed by the developers who build the Go Tools encoding utilities. The module counts, the check-digit arithmetic and the encoder behaviour described here were measured against a running engine rather than taken from other people's summaries.

Quick answers

Can I sell a product using a barcode generated here?

Only if the number was issued to you. The image this page draws is correct and will scan, but the *number* inside it has to be allocated to you by a GS1 member organisation before a retailer's system will accept it. Making up a number that starts with a registered prefix risks colliding with a number already assigned to someone else. Internal labels — shelves, bins, assets, work orders — need no allocation; use Code 128.

Does EAN-13 need 12 digits or 13?

Either works. The thirteenth is a check digit derived from the first twelve, so you can type either. Type 12 and it is appended and shown to you; type 13 and it is verified, with the expected digit named if it does not match.

Does a barcode starting with 690 mean the product was made in China?

No. 690–699 and 680–681 are the prefix ranges administered by GS1 China, and 489 Hong Kong, 471 Taiwan, 958 Macau. But GS1 states plainly that a member company may manufacture anywhere in the world and may license a prefix from the organisation of its choice, so the prefix identifies **who issued the number**, not where the goods came from.

Why does my barcode scan on screen but not on paper?

Almost always the quiet zone or a resized image. In order of how often it is the cause: the quiet zone was clipped by a label edge or a border; the image was resized in a layout tool so a module is no longer a whole number of printer dots; the module width is simply too small for the scanner and the print resolution. All three are decided before you print, and all three are shown on this page.

What a 1D barcode actually contains

A linear barcode is a run-length encoding of one string. Each character becomes a fixed pattern of bars and spaces, measured in modules — the width of the narrowest bar, written X. Code 128 spends 11 modules per symbol; a string of nine characters comes out 134 modules wide, because the total is 11 × (characters + 2) + 13: one start symbol, one check symbol, and a 13-module stop pattern.

Two things that are part of the symbol but look like empty space are where most home-made barcodes fail. The first is the quiet zone, the blank margin on each side; a scanner uses it to find the edge of the code, and a logo or a table border reaching into it makes the whole code unreadable. The second is the check digit in the retail symbologies, a single digit computed from the others that lets a scanner reject a misread instead of emitting a wrong product number.

Code 128   text = "HELLO-123"

  symbols = 1 (start) + 9 (data) + 1 (check)   = 11
  modules = 11 × 11 + 13 (stop)                = 134
  X = 3px                                      = 402 px
  + quiet zone 10X + 10X                       = 462 px

What this generator does

The check digit arithmetic, shown

Every digit with its weight, the weighted sum, and the modulo step. If you paste 13 digits and the last one is wrong, the page names the digit it should have been and offers the corrected number in one click — rather than reporting "invalid".

The quiet zone drawn on the preview

Not just a number in a table. The margin the specification requires is tinted on the preview, and it is asymmetric where the spec is asymmetric — EAN-13 wants 11X on the left and 7X on the right, not 10X on both.

Module width in dots, at your printer's resolution

One module at 203 dpi is 0.125 mm, at 300 dpi 0.085 mm, at 600 dpi 0.042 mm. The panel converts your chosen module width to millimetres at the resolution you select, so the printed size is a decision rather than a surprise.

Code 128 width, with the subset it chose

Digits pair up two per symbol in subset C, so eight digits take 79 modules where character-by-character encoding would take 123 — 35.8% narrower. The readout shows which subset was used and what it saved.

Fifteen symbologies, no upload

EAN-13, EAN-8, UPC-A, UPC-E, ITF-14, Interleaved 2 of 5, Code 128 with its A/B/C subsets, Code 39, Code 93, Codabar, MSI and Pharmacode. Everything is drawn by JavaScript in the page; no value is sent anywhere.

Batch to ZIP, with the failures explained

Paste one value per line and get SVG or PNG files in a ZIP. Rows that fail validation are not silently dropped — they land in skipped.txt with the reason, so a batch of 100 that returns 97 files tells you which three and why.

Other ways to produce the same barcode

bwip-js

npx bwip-js --bcid=ean13 --text=9780306406157 --scale=3 out.png

A BWIPP-derived engine with by far the widest symbology coverage — over a hundred, including 2D and postal — available as a CLI and a library. Worth reaching for when barcodes are generated by a build step, or when you need symbologies this page does not cover. Note that it adds no quiet zone unless you pass paddingleft/paddingright, and that height is in millimetres, not pixels.

python-barcode

python -m barcode ean13 9780306406157 -o out.svg

Convenient inside a Python pipeline and writes SVG by default. Covers the EAN/UPC family, Code 39 and Code 128; the more unusual symbologies and GS1 application identifiers are out of scope.

ZXing / zxing-cpp

Java and C++ libraries, generator plus reader

The usual choice when the same codebase has to both write and read codes. Its reader is the more famous half; for writing, the symbology coverage is narrower than BWIPP's.

Barcode fonts in Excel or Word

Install a Code 39 or Code 128 TrueType font, type the value

Popular because it needs no tooling, and the usual source of unscannable labels. Code 39 fonts require you to add the * delimiters yourself; Code 128 fonts require you to compute the check character yourself; and a font renders at whatever size the document says, with no control over module width.

GS1 member organisation

Apply for a company prefix

Not a generator, and not optional if the code has to work in retail. GS1 issues the number; drawing the bars is the easy part. Internal warehouse and asset labels need no allocation at all.

Worked examples

EAN-13: 12 digits in, check digit computed

978030640615
9780306406157

digit    9  7  8  0  3  0  6  4  0  6  1  5
weight  ×1 ×3 ×1 ×3 ×1 ×3 ×1 ×3 ×1 ×3 ×1 ×3
product  9 21  8  0  3  0  6 12  0 18  1 15

sum = 93,  93 mod 10 = 3,  check = (10 - 3) mod 10 = 7

The weights alternate 3 and 1 starting from the rightmost digit of the payload. Textbooks usually say "odd and even positions", which forces a different formula for each length; counting from the right gives one rule that covers EAN-13's 12 digits, UPC-A's 11 and EAN-8's 7. This particular number is the ISBN-13 of a well-known textbook, so the answer is checkable against the printed book.

A wrong check digit gets named, not rejected

9780306406158
The last digit should be 7, not 8.
[ Use 9780306406157 ]

The encoder underneath refuses the number outright — it raises ean13badCheckDigit. That is correct but useless: a number copied off a package is far more likely to have one mistyped digit than to be structurally wrong, and the only thing the person needs is which digit. So validation happens before the encoder is called.

Code 128 subset C halves the width of digits

12345678
subset C:  4 symbols  ->  79 modules
subset B:  8 symbols  -> 123 modules

saving: 35.8%

Subset C encodes two digits per symbol. The module count follows 11 × symbols + 35, so halving the symbol count nearly halves the width. This is why an all-numeric internal code is worth keeping all-numeric — adding a single letter forces the whole string back to one character per symbol.

An odd number of digits costs a switch symbol

12345
12345    (5 digits)  -> 79 modules
123456   (6 digits)  -> 68 modules
12345678 (8 digits)  -> 79 modules

Subset C cannot pair a leftover digit, so an odd-length numeric string pays for one extra switch symbol. The consequence is genuinely counter-intuitive and worth knowing before you design a numbering scheme: six digits are narrower than five, and five digits take exactly as much room as eight. Keep internal numeric codes even-length and you get the shorter barcode for free.

Module width, dots and millimetres

X = 3 modules px, printer = 203 dpi
1 dot @ 203 dpi = 0.125 mm
X = 3 dot        = 0.375 mm
EAN-13 symbol    = 95 modules
+ quiet 11X + 7X = 113 X  = 42.4 mm

A thermal printer can only place whole dots. Exporting at 1× and printing at the same resolution keeps every module a whole number of dots. Scaling the image afterwards in a layout tool does not: the module becomes a fractional number of dots, the printer rounds each bar independently, and the bar-to-space ratio drifts until scanners start failing.

How to generate a barcode

  1. 1

    Choose the symbology

    Retail products use EAN-13 (EAN-8 for small packs, UPC-A in North America). Cartons use ITF-14. Anything internal — shelf labels, asset tags, work orders — should use Code 128, which needs no registration and packs digits two per symbol.

  2. 2

    Type the data

    EAN-13 takes 12 or 13 digits, UPC-A takes 11 or 12, EAN-8 takes 7 or 8. Shorter forms have their check digit appended for you. Code 128 and Code 39 take variable-length text.

  3. 3

    Set the print size, not the zoom

    Pick the module width and the resolution of the printer you will use. The panel shows what one module works out to in millimetres at that resolution. Resizing the exported image in a layout tool is what breaks scannability, so set the size here instead.

  4. 4

    Export

    SVG stays sharp at any printed size and is what label software prefers. PNG at 2× or 4× is for places that cannot take vectors. Batch mode takes one value per line and returns a ZIP, with any rejected rows listed alongside their reason.

Errors this tool explains instead of just rejecting

"Invalid barcode" when one digit is mistyped

A 13-digit EAN-13 whose last digit does not match the other twelve is the most common real-world input. Being told which digit it should be takes one look; being told the number is invalid takes a trip to a separate calculator.

✗ Wrong
9780306406158  ->  invalid EAN-13
✓ Correct
9780306406158  ->  the last digit should be 7, not 8
                   [ Use 9780306406157 ]

Letting the tool silently append a check digit

Twelve digits in and thirteen out is the behaviour you want, but only if you are told about it — otherwise the number you print differs from the number in your spreadsheet and nobody knows which is authoritative.

✗ Wrong
in:  978030640615
out: barcode (13 digits, no mention)
✓ Correct
in:  978030640615
out: barcode + "check digit 7 added automatically"

Putting Chinese text in a Code 128

The encoder will not stop you. What comes out scans, but it does not decode to the characters you entered, and the barcode is noticeably wider than the text length suggests.

✗ Wrong
Code 128 <- 订单  (2 characters, 134 modules — same as 9 ASCII characters)
✓ Correct
Code 128 <- ORDER-2026-0042  (ASCII, and the width matches the content)

A quiet zone that a label border eats

Generators default to no margin at all. Placed against the edge of a narrow label, or inside a boxed design, the code loses the blank run a scanner needs to locate it and simply never reads.

✗ Wrong
|▐▌▐▐▌ ▐▌▐ ▌▐▐▌|   <- label edge touching the bars
✓ Correct
|    ▐▌▐▐▌ ▐▌▐ ▌▐▐▌    |   <- 11X left, 7X right kept blank

Scaling the exported image to fit the layout

Resizing to a "nice" physical size makes one module a fractional number of printer dots. The printer rounds each bar independently, the bar-to-space ratio drifts, and the code degrades gradually — which is worse than failing outright, because it passes the desk test and fails in the field.

✗ Wrong
export 1x, then scale to 38 mm in the layout tool
✓ Correct
set module width so the code is 38 mm at 300 dpi, export 1x, place at 100%

What people use this for

Checking a number before you print 5,000 labels
You have a 13-digit number from a spreadsheet and no way to tell whether the last digit is right. Paste it in: the weighted sum is laid out, and a wrong final digit is named rather than lumped under "invalid".
Internal shelf, bin and asset labels
Warehouse locations, fixed-asset tags and work-order numbers need no registered number at all. Code 128 encodes letters and digits, and pairs digits two per symbol, so a numeric location code stays compact.
Carton labels for a retail shipment
ITF-14 encodes the 14-digit shipping container number derived from the item's GTIN. It takes 13 or 14 digits here, and the check digit follows the same modulo-10 rule as EAN-13.
Reproducing a barcode from a photograph of a package
Read the digits printed under the bars, type them in, and compare. Because the check digit is verified, a digit you misread will be caught here rather than at the till.
Generating a run of sequential codes
Paste a column of values from a spreadsheet into the batch panel and download the whole set as SVG. Vector files can be dropped straight into label software without resampling.

How each symbology encodes

EAN-13 — 13 digits, and the quiet zone is asymmetric
Twelve digits of payload plus one check digit. The quiet zone is 11X on the left and 7X on the right; a symmetric margin either wastes space or clips the left edge. The human-readable digits are part of the specified layout, with the first digit sitting outside the bars on the left — which is why centring that text, as some generators do, quietly eats into the left quiet zone.
UPC-A and UPC-E — the same number, two lengths
UPC-A is 11 digits plus a check digit and uses the same modulo-10 rule as EAN-13; a UPC-A number is an EAN-13 with a leading zero. UPC-E is a 6-digit compressed form for small packages, reconstructed to the full number by the scanner rather than being a different number.
Code 128 — three subsets, chosen for you
Subset A covers control characters and upper case, B covers the printable ASCII range including lower case, C encodes two digits per symbol. Automatic mode switches between them to get the shortest encoding, which is why the readout shows the subset it landed in: C for even-length digits, CB when an odd length forced a switch, B for anything with a non-digit.
Code 128 cannot hold Chinese, Japanese or Korean text
Its character set stops at Latin-1. Feeding CJK text to the encoder does not raise an error — it silently produces a wider barcode whose content is no longer what you typed (one Han character occupies the symbol width of five ASCII characters). Because the failure is silent, this page rejects such input up front instead of drawing a barcode you would only discover was wrong after printing.
Code 39 and Code 93 — self-checking, no registration
Code 39 encodes digits, upper-case letters and seven symbols, needs no check character, and is readable by almost any scanner ever made; the trade-off is width, at roughly 13 modules per character. Code 93 is denser and adds two mandatory check characters. Both remain common in industrial and military labelling.
ITF-14 and Interleaved 2 of 5 — pairs of digits
Interleaved 2 of 5 encodes digits in pairs — one digit in the bars, the next in the spaces — so it only accepts an even count; an odd-length value gets a leading zero, which changes the encoded number. ITF-14 is the fixed 14-digit carton form and is normally printed with a heavy border, the bearer bar, whose job is to stop a partially damaged edge from being read as a short code.

Making a barcode that actually scans

Decide the printed size here, then never resize the image
Set module width and resolution in the appearance panel and export at 1×. Dragging the corner of the image in Word, Illustrator or a label designer re-samples the modules to a fractional number of printer dots, and uneven bars are the single most common cause of a barcode that scans on screen but not on paper.
Leave the quiet zone genuinely blank
The tinted strips on the preview are part of the symbol. Nothing may sit in them — no border, no logo, no neighbouring text, and no edge of the label. If your label is too narrow to hold them, reduce the module width rather than cropping.
Prefer SVG for anything that gets printed
Vector output has no resolution, so the printer driver rasterises the bars once, at its own device resolution. A PNG has already committed to a pixel grid, and if that grid does not match the printer's the bars get resampled.
Keep internal numeric codes even-length
Code 128 pairs digits two per symbol; an odd count costs an extra switch symbol, so a five-digit code is wider than a six-digit one. If you are designing a numbering scheme from scratch, this is free width.
Test with the scanner that will actually read it
Print one label on the real printer, at the real size, on the real stock, and scan it with the real device. Phone camera apps are far more forgiving than a laser scanner at a fixed distance, and thermal stock and ribbon combinations vary in how much the ink spreads.

Frequently asked questions

Can I use a barcode generated here on a product in a shop?
The graphic is valid and will scan, but a retail barcode is only usable if the number encoded in it was allocated to you. Numbers are issued by GS1 member organisations — the China organisation for mainland China, and the equivalent body in each other market. This tool draws the bars; it does not assign numbers, and no online generator can. If the labels are for your own warehouse, shelves or fixed assets, no allocation is needed at all and Code 128 is the right choice.
How is the EAN-13 check digit calculated?
Take the twelve digits, and working from the rightmost one multiply alternately by 3 and 1. Add the products. The check digit is whatever brings that sum up to the next multiple of ten — formally (10 - sum mod 10) mod 10. For 978030640615 the sum is 93, so the check digit is 7. This page lays the whole calculation out under the input. The same rule covers UPC-A's 11 digits, EAN-8's 7 and ITF-14's 13, because counting weights from the right makes the length irrelevant.
What does a prefix like 690 or 489 tell me?
It identifies the GS1 member organisation that issued the number. 690–699 and 680–681 are administered by GS1 China, 489 by GS1 Hong Kong, 471 by GS1 Taiwan, 958 by GS1 Macau, and 978–979 are reserved for ISBNs. It does not tell you the country of manufacture: GS1's own position is that member companies can produce goods anywhere and can license a prefix from whichever organisation they choose. The widely shared claim that 690 means "made in China" has been checked and rejected by several fact-checking organisations for exactly this reason.
Which symbology should I choose?
If the item is sold at retail, the choice is made for you: EAN-13, or EAN-8 where the pack is too small, or UPC-A in North America, with ITF-14 on the shipping carton. For anything internal, use Code 128 — it takes letters and digits, needs no registration, and compresses numeric data to two digits per symbol. Code 39 is worth considering only when you have to feed a very old scanner, since it is around 40% wider for the same content.
Why is my five-digit Code 128 wider than a six-digit one?
Because subset C packs two digits into each symbol and cannot pair an odd leftover, so an odd-length numeric string pays for one extra subset-switch symbol. Five digits come out 79 modules wide and six come out 68 — and five digits happen to be exactly as wide as eight. If you are still designing your numbering scheme, making the codes even-length costs nothing and gives you a narrower label.
What is the quiet zone and how much do I need?
It is the blank margin on either side of the bars, measured in modules (X). A scanner uses that blank run to find where the code begins, so it is part of the symbol rather than decoration. EAN-13 requires 11X on the left and 7X on the right — asymmetric, which catches out generators that apply one margin to both sides. UPC-A wants 9X each side, EAN-8 7X, and Code 128, Code 39 and ITF-14 at least 10X. On this page the required margin is tinted on the preview so you can see whether your label leaves room.
Can a barcode contain Chinese characters?
Not a 1D barcode of the usual kinds. Code 128 stops at Latin-1, and Code 39 is narrower still. Worse, most encoders do not refuse CJK input — they emit a barcode that scans but decodes to something other than what you typed, and is conspicuously wider than the character count suggests. This page blocks it instead. If you genuinely need to carry Chinese text in a scannable symbol, use a QR code generator — QR has a dedicated Kanji mode and no such limit.
SVG or PNG?
SVG for anything that will be printed. It has no resolution of its own, so the printer rasterises the bars once at its native resolution and every module lands on a whole dot. PNG has already committed to a pixel grid; if that grid does not line up with the printer's, the bars get resampled and the bar-to-space ratio drifts. Use PNG only where vectors are not accepted, and export at 2× or 4× so there is resolution to spare.
How do I generate a lot of barcodes at once?
Open the batch panel, paste one value per line — a column pasted straight out of a spreadsheet works — pick SVG or PNG, and you get a ZIP named after each value. Rows that fail validation are not silently skipped: they are collected in skipped.txt with the reason, so a batch of 100 that returns 97 files tells you which three failed and why. Everything happens in the browser, so the size of the batch is limited by your machine, not by a server quota.
What resolution should I print at?
Whatever your printer actually is — the point of choosing it here is that the page can tell you what one module means in millimetres. At 203 dpi, the common thermal resolution, one dot is 0.125 mm, so a three-dot module is 0.375 mm. At 300 dpi a dot is 0.085 mm and at 600 dpi 0.042 mm. Higher resolution lets you use a smaller module, which matters when the label is small; it does not make a badly sized code scan better.
Can this page read a barcode from an image?
No — it only generates. Reading a printed 1D barcode from a photograph is a different problem and needs a different tool. The QR decoder elsewhere on this site handles QR codes only and will not decode EAN-13 or Code 128. Nor can this page look up what product a number belongs to; that requires a GS1 product database.
Is anything uploaded?
No. The encoder is a JavaScript module that loads into the page, and every barcode — including the whole of a batch run and its ZIP — is produced on your own machine. Nothing you type is sent anywhere, written to a URL, or kept after you close the tab; only the appearance settings (module width, bar height, resolution) are remembered locally so you do not have to set them again.

Related Tools

View all tools →