Browser-based image tool · values → SVG, PNG or PDF label sheet

Barcode Generator

Type or load one value per line, pick Code 128, EAN-13, EAN-8, UPC-A or Code 39, and the check digit is worked out or verified for you. Save a single barcode as SVG or PNG, or put the whole list on an A4 or Letter sheet of labels. The bars are drawn by script on this page; your values are not uploaded, and this tool does not save them in local storage or session storage.

Values and settings

Symbology

Spaces at the ends of a line are ignored. A .csv file gives the first column of each row; a .txt file gives each line. Up to 1 MB and 2,000 values. You can also drop a file on this box.

The narrowest bar or space.

Barcode

BIN-A07-2291
Scanner reads
BIN-A07-2291
Code sets
B → C (C packs two digits into each symbol)
Size
156 modules of bars, 352 × 136 px as SVG, 704 × 271 px as PNG at 2×

3 valid

Pick a line to preview and download it.

Label sheet (PDF)

Labels to print

24 labels per page, 1 page, each label 63.3 × 34.6 mm. Modules print 0.305 mm wide (set by the widest code) and bars 15.2 mm tall. Print at 100% or "actual size", not "fit to page".

Barcode Generator

Operator: Abdulla Al Fahad. How tools are built and checked

A barcode is only useful if the reader at the other end gets back exactly the characters you meant, and several common mistakes are made before anything is printed: a check digit worked out by hand, a leading zero lost in a spreadsheet, a lowercase letter typed into a symbology that has none. The generator catches those three for Code 128, EAN-13, EAN-8, UPC-A and Code 39: it adds or verifies the check digit, flags a number that is one digit short, and names the character a symbology cannot hold. It also draws the blank quiet zone each symbology needs on both sides of the bars unless you narrow it yourself.

Type one value or paste a few hundred, one per line. Each line is validated on its own and either drawn or given a plain reason it cannot be. You can save the selected barcode as an SVG for design software or a PNG at one to four times its pixel size, or send the whole list (or one value repeated) to a PDF sheet of labels sized for A4 or US Letter paper.

Key features

  • Five symbologies: Code 128, EAN-13, EAN-8, UPC-A and Code 39
  • Check digits worked out when missing and verified when typed, with the expected digit named on a mismatch
  • Code 128 code set C switched on automatically for runs of four or more digits
  • Optional modulo 43 check character for Code 39
  • Module width, bar height and quiet zone controls, with each symbology's standard quiet zone as the default
  • Value printed under the bars, grouped under each half for EAN and UPC with longer guard bars
  • Bar and background colours, with a warning when the bars would be hard for a scanner to tell from the background
  • SVG and PNG (1× to 4×) downloads for the selected value
  • PDF label sheet on A4 or Letter: 1 to 8 labels across, 1 to 30 down, margin, gap and optional cutting lines
  • Values typed, pasted, or loaded from a .txt list or the first column of a .csv

What each barcode type accepts and produces

Code 128 accepts any plain ASCII character, from the control codes through letters, digits and punctuation, up to 80 characters. The encoder picks code sets the way the Code 128 standard recommends: code set B for ordinary text, code set C whenever four or more digits sit together (two digits per symbol), and code set A only for control characters such as a tab. That is why BIN-A07-2291 comes out at 156 modules instead of the 167 it would take in code set B alone.

EAN-13 takes 12 digits (the check digit is added) or 13 (it is checked). EAN-8 takes 7 or 8 digits and UPC-A takes 11 or 12. Spaces and hyphens inside the number are ignored, so 4006-3813 3393 is read as 400638133393. In UPC-A mode a 13-digit number that starts with 0 is accepted and the 0 is dropped, because UPC-A is the same symbol as an EAN-13 whose first digit is 0.

Code 39 takes capital letters, digits, the space and - . $ / + %, up to 40 characters, and the start and stop asterisks are added for you. Wide bars and spaces are drawn three modules wide. The modulo 43 check character is off by default and is a tick box away.

Outputs: an SVG sized in pixels with one module equal to the module width you choose (1 to 6 px), a PNG drawn at that size times 1, 2, 3 or 4 so every bar lands on whole pixels, and a PDF label sheet in which every bar is a filled vector rectangle and the text uses the standard Helvetica font. PNGs are capped at 16,384 px on a side and 40 megapixels; the SVG has no such cap.

How it works

Each non-empty line is trimmed and passed to the encoder for the chosen symbology. The encoder either returns a string of modules (one character per narrowest bar or space) or a reason the value is refused, such as a check digit that does not match or a character the symbology cannot hold. A bad line never stops the others; the list on the right shows every line with its result.

For EAN-13, EAN-8 and UPC-A the check digit is the GS1 modulo 10 digit: counting from the rightmost data digit, digits are multiplied by 3, 1, 3, 1 and so on, and the check digit is the amount that lifts the sum to the next multiple of ten. For Code 128 the check symbol is the start value plus each symbol value times its position, modulo 103; it is part of the bars but never printed or returned by the scanner.

The layout step turns the modules into rectangles. Neighbouring bar modules merge into one rectangle, quiet zones are added on both sides, and for EAN and UPC the guard bars (and, on UPC-A, the first and last digit's bars) reach down between the groups of digits. If you shrink the quiet zone so far that the first EAN-13 digit would fall off the edge, the margin grows just enough to keep the digit; it never shrinks below what you asked for.

The same layout feeds the on-screen preview, the SVG text, the PNG canvas and the PDF. For the label sheet, the page is divided into equal cells, one module width is chosen for the whole sheet from the widest barcode so every label matches, and each barcode is centred in its cell. pdf-lib, a PDF library, is downloaded from this site the first time you build a sheet; that request does not include your values. The list itself lives in the page's memory while the tab is open: encoding and drawing never send it to a server, and the generator does not copy it into local storage, session storage or IndexedDB.

Typical uses

  • Labelling storage bins and shelf locations so pickers can scan BIN-A07-2291 instead of reading it
  • Printing a sheet of 24 identical labels for a batch of boxes going to the same customer
  • Making EAN-13 artwork for a product whose number has been issued to the business, for the packaging designer
  • Checking that a supplier's 12-digit UPC-A list has correct check digits before importing it
  • Producing Code 39 part labels for older equipment or software that only reads Code 39
  • Making in-store codes for loose items with numbers in the restricted 20 to 29 prefix range, which GS1 sets aside for use inside one company

Building one

  1. Pick the symbology your scanner, warehouse system or retailer asks for. If nobody has specified one, Code 128 is the usual choice for internal codes.
  2. Type or paste the values, one per line, or load a .txt or .csv file. Press Example values to see a working set for the chosen symbology.
  3. Read the list: lines that need fixing show the reason in red, and EAN or UPC lines show the check digit that was added.
  4. Pick a line to preview it, then adjust module width, bar height, quiet zone, text and colours. Download it as SVG, or choose a scale and download a PNG.
  5. For printing many, set the page size and the number of labels across and down to match your label stock, check the module size reported under the settings, and download the PDF.
  6. Print the PDF at 100% (actual size), then scan one label with the scanner that will read them before printing the rest.

Example

Three lines, Code 128, module 2 px, bar height 100 px

BIN-A07-2291
BIN-A07-2292
RET-2026-00418

What the generator reports

BIN-A07-2291    code sets B → C, 156 modules (167 in set B only)
                 SVG 352 × 136 px; PNG at 4× is 1408 px wide
RET-2026-00418   code sets B → C → B → C, 178 modules (189 in set B only)

Label sheet, A4, 3 across × 8 down, 10 mm margin, no gap:
  24 labels per page, each 63.3 × 34.6 mm
  modules 0.305 mm wide, bars 15.2 mm tall

Same check for EAN-13 400638133393:
  odd positions 4+0+3+1+3+9 = 20
  even positions (0+6+8+3+3+3) × 3 = 69
  20 + 69 = 89, next multiple of ten is 90 → check digit 1
  printed as 4 006381 333931

Tips for best results

  • When a label is small, prefer Code 128 to Code 39: the same characters take fewer modules, and a long run of digits roughly halves in width.
  • Leave the quiet zone at its standard width unless a scanner test shows a narrower one still reads. The blank margin is what tells the scanner where the code starts.
  • Keep bars dark and the background light. Navy or dark green bars read well; red, orange and pink bars can disappear under the red light many scanners use.
  • For print, the SVG or the PDF is better than a PNG: they stay sharp at any size, while a PNG resized by another program can turn bars of equal width into unequal ones.
  • If your printer is a 203 dpi thermal label printer, a module of 0.25 mm is two of its dots; a module that falls between two dot counts prints with uneven bars.
  • Load a CSV that has the code in its first column; if the file has a header row, delete the header line from the box after loading.

Things to check before you rely on it

Printing the PDF with "fit to page" or "shrink to printable area" switched on scales every module down, and can push EAN and UPC modules under the smallest size the GS1 specification allows. Choose 100% or actual size in the print dialog.

A scanner set to Full ASCII Code 39 reads pairs such as +A as a lowercase a and $M as a control character. If your values contain $, %, + or / followed by a letter, either switch the scanner to standard Code 39 or use Code 128.

The Code 39 check character is part of what the scanner sends unless the scanner is set to check and remove it. PART-77A with the check character on arrives as PART-77AM, which will not match a database that holds PART-77A.

Cutting EAN-13 or UPC-A bars much shorter than usual makes them harder to read at a till, where scanners sweep across the code at angles. Keep bar height generous on retail packaging.

Spreadsheets drop leading zeros and turn long numbers into scientific notation such as 4.00638E+12. Once that has happened the original digits are gone; set the column to text at the source and export again, because no edit to the damaged number can recover them.

A tab pasted from a spreadsheet inside a Code 128 value is encoded as a real tab, which a keyboard-style scanner will type as a Tab key press. The text under the bars shows it as a space, and the preview notes it.

Common errors and how to fix them

"The last digit is 2, but the first 12 digits give a check digit of 1."
The 13-digit number has a typo, often two neighbouring digits swapped. Compare it with the source, or enter only the first 12 digits and let the generator add the correct check digit.
"EAN-13 needs 12 digits ... This value has 11. A leading zero is often lost ..."
The number was stored as a number somewhere and its leading 0 was dropped. Put the zero back, and format that column as text in the spreadsheet so it stays.
"Code 39 has no lowercase letters."
Retype the value in capitals, as the message suggests, if the system that reads it does not care about case. If lowercase matters, choose Code 128, which encodes it directly.
"This is a 13-digit number that does not start with 0, so it has no UPC-A form."
Only EAN-13 numbers beginning with 0 can be drawn as UPC-A. Switch the symbology to EAN-13 for this number.
The label sheet says modules would be under 0.1 mm, or that labels leave too little room for the bars.
The grid is too dense for the longest value. Reduce the labels across (for width) or down (for height), shorten the values, or turn off the text line to give the bars more height.
"The text line does not fit these 63.3 mm labels, even at the smallest size the sheet prints it (5 pt)"
The value printed under the bars is wider than the label, or its digits would collide with the guard bars, so printing it would spill into the next label. Press Turn off the text line (the message also says what module size the bars alone would get), or use fewer labels across so each label is wider.
"This PNG would be ... over the 16,384 px limit for one side."
Lower the PNG scale or the module width. If you need a very large image, download the SVG and export it from a vector editor at the size you need.

Best practices

  • Test one printed label with the actual scanner, at the size it will be printed, before printing a batch.
  • Only put EAN-13, EAN-8 or UPC-A numbers that have been assigned to your business on goods sold through shops; use Code 128 for everything internal.
  • Keep the value printed under the bars, so a person can type it if a label is damaged.
  • Use one symbology per type of label, so staff and scanners are never set up for the wrong one.
  • Keep the source list as the master copy and regenerate labels from it rather than editing downloaded files.

Which symbology to choose

Retail goods that pass through a shop's checkout use EAN-13 in most of the world and UPC-A in the United States and Canada, with EAN-8 for packs too small for a full EAN-13. These numbers come from GS1, the body that runs the retail numbering system, and a scanner at a till looks them up in the shop's product file, so the symbology is decided by the number you were issued, not by preference.

For anything internal (bins, assets, documents, batches, tickets) Code 128 is the practical default. It holds letters, digits and punctuation, checks itself with a built-in check symbol, and is compact. Code 39 is older, wider and limited to capitals and a few symbols, but some equipment and some industry rules still call for it; use it when you are told to.

How big the label sheet makes each barcode

The sheet divides the printable area into equal cells after the page margin and the gaps, then leaves 1.5 mm of padding inside each cell. It finds the widest barcode in your list, including its quiet zones, and picks one module width that lets it fit, up to a maximum of 1 mm. Every label then uses that module width, so a short value is not drawn bigger than a long one.

Bar height follows the shape of the on-screen settings: with a 2 px module and 100 px bars the bars are 50 modules tall, so a 0.305 mm module gives 15.2 mm bars. If the cell is not tall enough, the bars are shortened to fit, and the sheet refuses to build if less than 3 mm would be left. The summary under the settings states the label size, module width and bar height before you download.

The text line is fitted too. Its font size is nine module widths for EAN and UPC and eight for the others, but never below 5 pt, so on a dense grid a long value's text can end up wider than its bars. The sheet then makes every barcode narrower until the text fits inside the label as well; if even 5 pt text cannot fit, or EAN and UPC digits would run into the guard bars, it refuses and offers to turn the text line off rather than letting text run into the neighbouring label. A 72-digit Code 128 value on A4 labels three across is one such case: with the text off, its bars fit at 0.140 mm modules with no quiet zone.

For EAN and UPC the summary warns when the module drops below 0.264 mm, the smallest size the GS1 specification allows for those symbols at retail checkouts. For the other symbologies it warns below 0.25 mm, the point where a 203 dpi printer can no longer give each module two whole dots.

Symbologies and label features left out

It draws barcodes; it does not read them, assign numbers or register them anywhere. Check that a printed code scans with your own scanner or a phone app you trust.

  • No UPC-E, ITF-14, Codabar, GS1-128 application identifiers or EAN-2 and EAN-5 add-ons.
  • No QR codes or other two-dimensional codes (there is a separate QR code generator on this site).
  • Code 128 is limited to plain ASCII; accented letters and typographic quotes and dashes are refused with the character named.
  • Label sheets use one module size and one symbology for the whole sheet, and do not print extra text such as product names beside the barcode.
  • A run takes up to 2,000 values and a 1 MB file; a sheet holds up to 2,000 labels on up to 200 pages.

Frequently asked questions

Why is my Code 128 barcode narrower than the one another program made for the same text?

Probably because the digits were packed into code set C. Four or more digits in a row are encoded two per symbol, which shortens the bars without changing what the scanner returns. 123456 takes 68 modules here instead of 101.

Does the check digit appear in what the scanner reads?

For EAN-13, EAN-8 and UPC-A, yes: it is the last digit of the number. For Code 128, no: the check symbol is verified by the scanner and dropped. For Code 39 it depends on the scanner's settings, which is why the check character is optional here.

Can I make a UPC-A from an EAN-13 number?

Only if the EAN-13 starts with 0. Paste the 13-digit number in UPC-A mode and the leading 0 is dropped; the bars are identical either way.

Which file should I give a printer or designer?

The SVG for a single barcode placed in artwork, or the PDF sheet for labels. Both are vector, so bars keep their exact widths at any size. Ask them not to stretch the barcode in one direction only.

Will my labels line up with pre-cut label sheets?

Set the page margin, the gap and the number of labels across and down to the measurements printed on the label packet, turn off the cutting lines, and print one sheet on plain paper first. Hold it against a label sheet to check the alignment before using the real stock.

Why does the label sheet refuse a long value that the single PNG draws without trouble?

A PNG simply gets wider for a longer value, but a label has a fixed width. On the sheet the text line cannot shrink below 5 pt, so with labels three across an A4 page, a value of 70 or more digits is too wide to print under its bars. Turn off the text line for that sheet, put fewer labels across, or keep long values for the single-barcode downloads.