Barcode Generator

Published Updated

Create Code 128, EAN-13 and UPC-A barcodes with automatic check digits and download them as PNG or SVG — free and processed entirely in your browser.

About the Barcode Generator

This barcode generator creates scannable Code 128, EAN-13 and UPC-A barcodes in your browser and lets you download them as PNG or SVG. Choose the type, enter the text or number and the barcode appears at once, drawn from the official bar patterns by code that runs on this page. There is nothing to install, no account and no watermark, so it suits a quick label for a shelf, a box, a file folder or a spreadsheet of stock numbers.

Code 128 holds any standard keyboard character and picks the most compact of its code sets automatically, switching to the dense numeric set for runs of digits so long numbers stay short. EAN-13 and UPC-A are the retail product symbols. Type the number without its last digit and the tool calculates the check digit; type the full number and it checks the digit and offers a one-click fix when it is wrong. Clear messages explain anything that cannot be encoded, such as a letter in an EAN number or a character outside plain ASCII.

You control how the barcode looks. Set the bar width in pixels, the bar height and the quiet zone, the blank margin that scanners need on both sides, and decide whether the number is printed beneath the bars, with the usual guard bars and layout for EAN and UPC. The preview always shows exactly what will be downloaded, and its size is shown in pixels. Barcodes are always black on white for the best scan results. Need a two-dimensional code instead? Try our QR Code Generator.

What the encoder makes of a few inputs

Results from the page's own encoder in Node 22.23.1 at the default settings: bars of 3 px per module, 100 px high, the standard quiet zone and the number shown. A Code 128 symbol count includes the start, check and stop symbols.

You typeTypeEncoded asSymbols and modulesImage
ABC-123Code 128Code set B10 symbols, 112 modules396 x 131 px
12345678Code 128Code set C, two digits per symbol7 symbols, 79 modules297 x 131 px
1234567Code 128Set B for the first digit, then set C8 symbols, 90 modules330 x 131 px
INV-2026-000184Code 128Set B, then set C for the last six digits16 symbols, 178 modules594 x 131 px
a, a Tab character, bCode 128Set B with one SHIFT symbol for the Tab7 symbols, 79 modules297 x 131 px
123456789012EAN-13Check digit 8 added: 123456789012895 modules339 x 131 px
12345678901UPC-ACheck digit 2 added: 12345678901295 modules339 x 131 px

The encoder chooses the code sets with a shortest-path search. On 20,000 random strings of 1 to 12 characters (digits, letters, spaces and control characters) its symbol count equalled that of a separate brute-force search for the shortest encoding every time. The EAN-13 and UPC-A check digit matched a separate implementation of the GS1 check digit rule (weights 3 and 1 from the right, modulo 10) on 100,000 random numbers. 1234567890123 is refused with The check digit is wrong. The last digit of 1234567890123 should be 8, not 3, and a button offers the corrected number.

Image width, margins and limits

Width in pixels from the same code, for one example of each type:

SettingCode 128 ABC-123EAN-13UPC-A
Bar width 1 px132113115
Bar width 3 px (default)396339339
Bar width 10 px1,3201,1301,130
Wide quiet zone, 3 px456393393
No quiet zone, 3 px336300315

The standard quiet zone is 10 modules on each side for Code 128, 11 on the left and 7 on the right for EAN-13, and 9 on each side for UPC-A; Wide doubles it. Turning the number off takes the height from 131 to 112 px at the default settings. Code 128 accepts up to 80 characters (81 gives Code 128 is limited to 80 characters here. You entered 81. Shorten the text.), and no image may exceed 10,000 px: 80 letters at a bar width of 10 px make a 9,350 px image, while 80 characters that mix letters and Tab characters need 11,550 px and get a message asking for a smaller bar width or shorter text.

PNG and SVG checked pixel by pixel

The page's real component was run in Google Chrome 156, Chromium 153 (Playwright build, not Google Chrome), Firefox 155 and Playwright's WebKit build (not the Safari app) for seven settings: all three types, bar widths from 1 to 10 px, heights from 60 to 400 px, all three quiet zones, number on and off. For each, the downloaded PNG was decoded, and the SVG preview was drawn at 100% on a canvas by the same browser.

CheckResult in all four engines
PNG sizeExactly the size the layout states, from 198 x 82 to 2,180 x 440 px
Pixels in the bar area of the PNGEvery one pure black or pure white, and black exactly where the encoder has a dark module: 0 wrong pixels out of 1,144,830
The SVG drawn at 100%The same: 0 grey and 0 wrong pixels in the bar area

The check covered the rows that every bar crosses; the digits printed below the bars were not part of it.

How to Make a Barcode

  1. Step 1

    Choose the type

    Pick Code 128 for text and numbers, EAN-13 for retail products or UPC-A for US and Canadian products.

  2. Step 2

    Enter the value and set the size

    Type the text or digits. EAN-13 and UPC-A check digits are added or verified for you. Set the bar width, bar height and quiet zone, and choose whether to print the number under the bars.

  3. Step 3

    Download PNG or SVG

    Save the barcode as a PNG for documents or as an SVG that stays sharp at any print size.

Frequently Asked Questions

Are my numbers sent anywhere?

No request carries them. The barcode is encoded and drawn in your browser by the page's own code, which makes no network or storage calls; making seven barcodes and their PNG files in each of four test browsers sent no request to a server. There is no account.

Which barcode type should I choose?

Use Code 128 for internal labels, shipping, inventory and asset tags, because it holds letters, digits and symbols. Use EAN-13 or UPC-A only for numbers that were issued to your product, for example through GS1, because shops and marketplaces check them against a registry.

What is the check digit?

It is the last digit of an EAN-13 or UPC-A number, calculated from the other digits so a scanner can catch a typing error. Enter one digit fewer and the tool adds it; enter the full number and it is verified, with a one-click fix if it is wrong. Code 128 has its own check symbol, which is always added automatically.

Why is the barcode always black on white?

Scanners read the contrast between dark bars and a light background, and black on white is the most reliable combination, so this tool does not offer colours. Keep the quiet zone, the blank margin on both sides, and do not stretch the image to a different width or height.

Should I download PNG or SVG?

SVG is vector artwork, so it prints sharply at any size and is best for labels and print shops. PNG is a picture of fixed size that is easy to paste into documents and web pages; choose a larger bar width if you need a bigger image.

Can I make QR codes or Code 39 here?

This tool makes Code 128, EAN-13 and UPC-A barcodes. For two-dimensional codes use our QR Code Generator.

Why is a Code 128 barcode of digits shorter than one of letters?

Code 128 has a set that packs two digits into one symbol. 12345678 needs 7 symbols and gives a 297 px wide image at the default settings, while ABC-123 needs 10 symbols and 396 px. With an odd number of digits the first one goes in a letter set and the rest in pairs, so 1234567 takes 8 symbols.

How wide will my barcode image be?

Width grows in step with the bar width: ABC-123 is 132 px at 1 px per bar module, 396 px at the default 3 px and 1,320 px at 10 px, and an EAN-13 or UPC-A number is 339 px at the default. The quiet zone adds to that, and the height is the bar height plus the number and margins, 131 px at the defaults.

Will the PNG scan as well as the SVG?

At the size it is saved, they are the same picture: in four test browsers every pixel in the bar area of the PNG was pure black or white and matched the bar pattern exactly, and the SVG drawn at 100% gave the same pixels.

Related Tools