Skip to content

Barcode Generator

Create Code 128, EAN-13, UPC-A, and Code 39 barcodes instantly

0 characters

Generate Industry-Standard Barcodes from Any Data

Barcodes encode data as a pattern of parallel lines that optical scanners read at retail checkouts, warehouses, shipping labels, libraries, and laboratories. This tool generates four of the most widely used one-dimensional barcode formats — Code 128, Code 39, EAN-13, and UPC-A — directly in your browser. Enter your data, choose a format, and download a print-ready PNG.

Code 128: The Universal Format

Code 128 is the most versatile barcode symbology. It encodes all 128 ASCII characters — uppercase, lowercase, digits, punctuation, and control codes — in a compact format. It uses three code sets (A, B, C) and automatically switches between them for optimal density: code set C encodes digit pairs in a single symbol, making it very efficient for numeric data. Shipping labels (GS1-128), inventory systems, and general-purpose labeling all use Code 128.

EAN-13 and UPC-A: Retail Product Codes

EAN-13 is the international standard for retail product identification — the barcode on virtually every packaged product sold worldwide. It encodes exactly 13 digits including a check digit that the tool calculates automatically. UPC-A is the 12-digit variant used in the United States and Canada. Both are subsets of the same system: a UPC-A code is an EAN-13 with a leading zero. If you have a GS1-assigned product number, these are the formats you need.

Code 39: Simple and Self-Checking

Code 39 encodes uppercase letters (A–Z), digits (0–9), and seven special characters (- . $ / + % and space). It is used in US Department of Defense logistics (LOGMARS), automotive manufacturing, and healthcare because it is self-checking — each character is independently decodable without a checksum. The tradeoff is lower density: Code 39 barcodes are wider than Code 128 for the same data, so they need more label space.

Sizing for Reliable Scanning

A barcode must have a minimum bar width (the narrowest line) that a scanner's optics can resolve, and enough height for the laser to sweep across reliably. For print, a narrow bar of at least 0.26 mm and a height of at least 15 mm are recommended for Code 128. Retail barcodes (EAN/UPC) have their own sizing specification called the magnification factor, with 100% (nominal size) being 37.29 mm wide for EAN-13. Always include quiet zones — blank space on either side — of at least 10 narrow bar widths.

Browser-Side Generation

The barcode is drawn on an HTML canvas entirely in JavaScript. No data is sent to a server, which makes the tool safe for encoding internal product codes, serial numbers, patient IDs, and other sensitive identifiers. The generated PNG can be saved, printed, pasted into labels, or embedded in documents without any dependency on an external service.

$ faq

Which barcode format should I use?
Code 128 is the best general-purpose choice — it encodes any ASCII character compactly and is supported everywhere. EAN-13 is the international retail standard (13-digit product codes). UPC-A is the 12-digit US/Canada retail standard. Code 39 is used in logistics, government, and defense because it is simple and self-checking, but it only supports uppercase letters, digits, and a few symbols.
What is a check digit?
A check digit is an extra digit appended to the barcode data, calculated from the other digits using a specific formula. It allows scanners to detect errors — if the scanned check digit does not match the computed one, the scan is rejected. EAN-13 and UPC-A require check digits; this tool calculates them automatically if you enter 12 or 11 digits respectively.
Can Code 128 encode any text?
Yes. Code 128 supports all 128 ASCII characters including lowercase letters, digits, punctuation, and control characters. It automatically selects the most compact encoding mode (A for control characters, B for mixed text, C for digit pairs) and switches between them as needed.
Why is my EAN-13 or UPC-A barcode rejected?
EAN-13 requires exactly 13 digits (or 12 — the tool adds the check digit). UPC-A requires exactly 12 digits (or 11). If you enter letters or the wrong number of digits, the tool will show an error. Make sure your input contains only digits and meets the length requirement.
What size should the barcode be?
For reliable scanning, a barcode should be at least 1 inch (2.5 cm) wide for UPC/EAN and at least 0.5 inches tall. On screen, 300 pixels wide is usually sufficient. For printing, use a high bar height (80–100 pixels) and make sure the quiet zones (white space) on either side are preserved.
Can I change the barcode colors?
Yes. You can set custom bar and background colors. For reliable scanning, maintain high contrast — dark bars on a light background. Red backgrounds should be avoided because many barcode scanners use red lasers that cannot distinguish red from white.
Is my data sent to a server?
No. The barcode is generated entirely in JavaScript using a canvas element in your browser. No data is transmitted anywhere, making it safe for internal product codes, serial numbers, and other sensitive identifiers.