Barcode Generator

Generate a Code 128 or EAN-13 barcode as crisp SVG or high-resolution PNG, with the check digit calculated.

Loading tool…

Everything runs in your browser. Nothing is uploaded, nothing is stored on a server, and closing the tab clears it.

What the Barcode Generator does

This barcode generator will generate a Code 128 or EAN-13 barcode as crisp SVG or high-resolution PNG, with the check digit calculated. Everything runs inside this page, so the work happens on your own device rather than on a server. It is most often used for labelling your own stock, assets or inventory with Code 128. People using this often want the HEIC to webp converter next.

How to use it

  1. Choose Code 128 for any text, or EAN-13 for a retail product code.
  2. Type your data. For EAN-13, enter the first 12 digits and the check digit is worked out for you.
  3. Adjust bar height and width if the scanner or the label needs it.
  4. Download SVG for printing, or PNG if something will not take vector.

How it works

The output is SVG, and that is the decision that determines whether your barcode scans. A barcode is a precise pattern of bar widths, and a bitmap scaled up produces soft, anti-aliased edges that a scanner reads as the wrong width or fails to read at all. Vector output stays mathematically exact at any size and at any printer resolution. The PNG option renders at three times the display size for the same reason.

Code 128 encodes any printable ASCII and switches automatically between its subsets. That matters for width: a long numeric string encoded in subset C packs two digits into each symbol, so a sixteen-digit number comes out around half the width it would in subset B. The checksum is a weighted modulo-103 sum over the encoded values, calculated here and appended automatically.

EAN-13 is the retail barcode on consumer products and it is far stricter. Thirteen digits, the last of which is a check digit derived from the other twelve by a weighted sum — enter twelve and it is calculated, enter thirteen and it is verified. If you paste a real product code and it reports an invalid check digit, you have mistyped a digit. The first digits identify the country prefix and the manufacturer, and those are allocated by GS1: you cannot invent a valid retail barcode, only encode one you have been assigned.

The quiet zone — the blank margin either side of the bars — is included because scanners genuinely require it and barcodes fail without it. The commonest real-world cause of an unscannable barcode is a design that crops hard to the edge of the bars, which leaves the scanner no way to find where the pattern starts.

When to use it

  • Labelling your own stock, assets or inventory with Code 128.
  • Encoding a product code you have been assigned by GS1.
  • Generating serial or reference labels for a small business.
  • Checking whether an EAN-13 number you have is valid.

Common mistakes to avoid

  • Using a PNG scaled up for print. Soft bar edges are the main reason barcodes fail to scan — use the SVG.
  • Cropping away the quiet zone. Scanners need the blank margin either side to find the start of the pattern.
  • Inventing an EAN-13 for a retail product. Those prefixes are allocated by GS1 and a made-up one belongs to someone else.

Frequently asked questions

Which barcode type should I use?

Code 128 for anything internal — stock labels, asset tags, references — because it takes any text and any length. EAN-13 only if you have been allocated a product code by GS1, since the number identifies a registered manufacturer.

Why does my EAN-13 say the check digit is wrong?

Because the thirteenth digit must be derived from the first twelve by a weighted sum. If a real product code fails, a digit has been mistyped. Enter just the first twelve and the correct check digit is calculated for you.

Should I download SVG or PNG?

SVG for anything printed. It stays mathematically exact at any size, where a scaled bitmap produces soft bar edges that scanners misread. Use PNG only for a system that cannot accept vector.

Related tools

See all image tools →