Barcode Generator

Generate 1D barcodes in Code128, EAN-13, EAN-8, UPC-A and Code39 formats. Download the result as a PNG image.

By Pankaj Kumar · DevToolsHub · Last updated May 2026

What is a barcode?

A barcode is a machine-readable representation of data in a visual, scannable format. Traditional 1D barcodes encode information in a series of parallel lines of varying widths and spacings. A barcode scanner reads the pattern of light and dark bars to decode the underlying data — typically a product identifier, serial number, or tracking code — in milliseconds.

This generator runs on ZXing.Net, which produces raw RGBA pixel data rather than a finished image file. The server encodes those pixels into a PNG itself using a small hand-written PNG writer rather than System.Drawing — a deliberate choice, since System.Drawing.Common has been restricted to Windows-only since .NET 6 and would be a poor fit for a cross-platform ASP.NET Core service.

Barcodes were first used commercially in 1974 when a pack of Wrigley's chewing gum was scanned at an Ohio supermarket using the newly standardised UPC code. Today, barcodes appear on virtually every physical product sold worldwide, as well as in logistics, healthcare, libraries, and manufacturing.

How to use this tool

  1. Type or paste the data you want to encode in the Barcode content field.
  2. Select the barcode format that matches your use case (see below).
  3. Adjust Width and Height in pixels to match your label size.
  4. Click Generate to create the barcode preview.
  5. Click Download PNG to save the image for use in your label design software.

Barcode formats — which one to choose

FormatData typeLengthTypical use
Code 128All 128 ASCII charactersVariableShipping labels, inventory, any custom text
EAN-13Digits only12 digits + check digitRetail product packaging worldwide (GTIN-13)
EAN-8Digits only7 digits + check digitSmall packaging where EAN-13 is too wide
UPC-ADigits only11 digits + check digitNorth American retail (GTIN-12)
Code 39A–Z, 0–9, special charsVariableIndustrial, automotive, US DoD labelling

Code 128 — the most versatile format

Code 128 is the best default for most applications. It supports the full ASCII character set (letters, numbers, punctuation, and control characters), uses efficient encoding with three sub-types (A, B, C) automatically selected by the encoder, and produces compact barcodes with high data density. It is used in GS1-128 labels (formerly EAN-128), which are the international standard for shipping and logistics. If you are unsure which format to use, choose Code 128.

EAN and UPC — retail product barcodes

EAN-13 and UPC-A are the international retail standards. If you are creating a barcode for a commercial product intended for sale in a physical store, you need to obtain a GTIN (Global Trade Item Number) from GS1 — a barcode you generate yourself using your own numbers will not work at a real retail point-of-sale. These formats are free to generate for internal use, prototyping, or testing purposes.

Check digits: EAN and UPC barcodes include a mathematically-derived check digit as the last digit. This tool calculates the check digit automatically — you only enter the data digits (12 for EAN-13, 7 for EAN-8, 11 for UPC-A).

Sizing your barcode for print

  • Minimum scan size: A Code 128 barcode should be at least 25 mm (1 inch) wide at standard magnification for reliable scanning at retail/warehouse distances.
  • Quiet zones: Scanners require a blank white margin (quiet zone) on each side of the barcode. This tool includes quiet zones in the generated image — do not crop them.
  • Print resolution: For print use, set the width to at least 300 px per inch of label width. A 2-inch label at 300 DPI should be at least 600 px wide.
  • Aspect ratio: Barcodes should be wider than tall. A 3:1 width-to-height ratio is common; never make a barcode taller than it is wide.

Common use cases

  • Product labels — generate a Code 128 barcode with your internal SKU or product ID for warehouse scanning
  • Asset tracking — label office equipment, IT assets, or library books with unique identifiers
  • Event tickets & passes — encode a booking reference or ticket number for gate scanning
  • Shipping and logistics — create GS1-128 compatible labels with order IDs or tracking numbers
  • Healthcare — Code 128 is used on patient wristbands and medication packaging
  • Retail prototyping — test EAN-13 or UPC-A barcodes in a point-of-sale system before ordering official GTINs
  • Inventory management — print barcodes for a small business stock system using a thermal label printer

Barcode vs QR code — which should you use?

1D barcodes (this tool) encode data in one dimension only — they hold less data (typically 20–80 characters) but scan faster on dedicated laser scanners and are the required format for retail checkout, GS1 logistics, and most industrial applications. QR codes (2D barcodes) hold far more data (up to 3,000 characters), can be scanned by any smartphone camera, and are ideal for URLs, Wi-Fi credentials, and consumer-facing applications. Use 1D barcodes when integrating with existing barcode scanner infrastructure; use QR codes for consumer/web use cases.

This tool is built with ASP.NET Core 8, Blazor Server, and ZXing.Net. It runs securely on Microsoft Azure.
Input Section
Any alphanumeric content
Barcode format
Size
Output Section

Enter content and click Generate to create your barcode.