How to use the Barcode Generator
Follow these steps to create a barcode suited to retail, inventory, logistics, healthcare, or testing workflows:
- Select Barcode Type: Choose the format that matches your purpose. CODE128 supports a broad character set, CODE39 is simple and widely recognized, EAN13 and UPC are common in retail, and Pharmacode is used in pharmaceutical tracking.
- Enter Barcode Data: Provide the value to encode. Each barcode type has its own requirements for allowed characters, length, and in some cases a valid check digit.
- Add Description: Optionally enter a short label or note that appears below the barcode in the preview and in the downloaded PNG output.
-
Configure Colors:
- Code Color: Sets the barcode line color.
- Background Color: Sets the barcode background.
- Scanning guidance: High contrast is generally safer than decorative low contrast combinations.
- Generate: Press Generate to validate the data and render the barcode preview. If the input is invalid, the page shows an error message instead of producing a malformed barcode.
- Download or Clear: Download saves the barcode as a PNG image. Clear resets the text fields, color selections, preview, and messages.
Barcode symbology comparison: choosing the right format
Barcode symbologies encode data using different patterns of bars and spaces. The GS1 General Specifications, the global standard for barcode usage in supply chains, define the requirements for retail and logistics barcodes. The following table compares the supported barcode types:
| Symbology | Character set | Length | Check digit | Primary use case |
|---|---|---|---|---|
| CODE128 | Full ASCII (128 characters) | Variable (1+) | Automatic | General-purpose, logistics, shipping labels |
| CODE39 | Uppercase letters, digits, space, -.$/+% | Variable (1+) | Optional | Non-retail inventory, government, military |
| EAN13 | Numeric (0–9) | 13 digits (fixed) | Required (validated) | Retail point-of-sale (GTIN-13) |
| EAN8 | Numeric (0–9) | 8 digits (fixed) | Required (validated) | Small retail items (GTIN-8) |
| UPC | Numeric (0–9) | 12 digits (fixed) | Required (validated) | North American retail (UPC-A) |
| ITF14 | Numeric (0–9) | 14 digits (fixed) | Required (validated) | Carton and pallet labeling (GTIN-14) |
| MSI | Numeric (0–9) | Variable (1+) | Optional | Warehouse inventory, shelf labeling |
| Pharmacode | Numeric (3–131070) | 1–6 digits | Not used | Pharmaceutical packaging and quality control |
Encoding principles: how barcodes represent data
All 1D barcodes encode data by varying the width and spacing of parallel bars and spaces. The ISO/IEC 15416 standard defines the quality requirements for linear barcode symbologies, including print quality measurement and grading. Each symbology uses a unique encoding scheme:
- CODE128: Uses three character sets (A, B, C) with start codes to switch between them. Set A encodes uppercase letters, punctuation, and control characters. Set B encodes uppercase and lowercase letters. Set C encodes numeric pairs with high density (two digits per bar-space pattern). The barcode automatically selects the most efficient encoding for the input data.
- CODE39: Encodes 43 characters plus a start/stop character using five bars and four spaces, three of which are wide (hence "3 of 9"). The wide-to-narrow ratio determines readability. CODE39 is self-checking, meaning a single printing defect is unlikely to produce a valid different character.
- EAN/UPC: These retail barcodes encode digits using a two-bar, two-space pattern per digit. EAN13 uses 13 digits: the first 2–3 digits represent the country code (GS1 prefix), the next 9–10 digits encode the company and product identifiers, and the final digit is a weighted modulo-10 check digit. The GS1 GTIN page explains how Global Trade Item Numbers are structured and assigned.
- ITF14: Interleaved 2 of 5 encodes pairs of digits, with the first digit represented by bars and the second by spaces in the same symbol. ITF14 is designed for outer-case carton labeling and includes bearer bars (a rectangular border) to protect the symbol during printing on corrugated materials.
- Pharmacode: A binary encoding system where each digit is represented by a series of bars of varying widths. Pharmacode can represent values from 3 to 131070 and is read in only one direction, making it suitable for high-speed pharmaceutical packaging lines.
Check digit calculation: ensuring data integrity
A check digit is a calculated value appended to the barcode data that allows scanners to verify the symbol was read correctly. The GS1 check digit calculator provides an interactive tool for verifying check digits manually. The following table shows the calculation methods for each supported format:
| Format | Calculation method | Weighting pattern | Example (data without check digit) |
|---|---|---|---|
| EAN13 | Modulo-10 | Odd positions × 1, even positions × 3 | 590123412345 → check digit = 7 |
| EAN8 | Modulo-10 | Odd positions × 3, even positions × 1 | 1234567 → check digit = 0 |
| UPC (UPC-A) | Modulo-10 | Odd positions × 3, even positions × 1 | 12345678901 → check digit = 2 |
| ITF14 | Modulo-10 | From the rightmost data digit: × 3, then alternate × 1 and × 3 | 1234567890123 → check digit = 1 |
To calculate a check digit manually, sum the weighted digits, divide by 10, and subtract the remainder from 10. If the remainder is 0, the check digit is 0. This tool validates the check digit you provide but does not calculate it automatically.
Barcode format specifications: data requirements and constraints
| Format | Allowed characters | Required length | Special constraints |
|---|---|---|---|
| CODE128 | ASCII 0–127 | 1 or more | Non-printable control characters are allowed but may not render visibly |
| CODE39 | A–Z, 0–9, space, -.$/+% | 1 or more | Lowercase letters are not supported; convert to uppercase |
| EAN13 | 0–9 | 13 digits | Must include valid check digit; GS1 prefix required for retail use |
| EAN8 | 0–9 | 8 digits | Must include valid check digit; used for small packages |
| UPC | 0–9 | 12 digits | UPC-A format; must include valid check digit |
| ITF14 | 0–9 | 14 digits | Must include valid check digit; bearer bars recommended |
| MSI | 0–9 | 1 or more | No standard check digit; used primarily in warehouse environments |
| Pharmacode | 0–9 | 1–6 digits | Value must be between 3 and 131070; no check digit |
Color and design guidelines for reliable scanning
Barcode scanners use red or infrared light to read bar patterns. The Scandit barcode scanning best practices guide provides detailed recommendations for optimizing barcode design. Key principles include:
- High contrast: Black bars on a white background provide the highest contrast ratio. Avoid colored bars on colored backgrounds, especially red bars (which are invisible to red-light scanners).
- Quiet zones: Every barcode requires a clear margin (quiet zone) on both sides, typically 10–20 times the width of the narrowest bar. Without adequate quiet zones, scanners may fail to recognize the start and stop patterns.
- Minimum height: Barcodes should be tall enough to allow scanning from various angles. A height of at least 20–25% of the total symbol length is recommended for retail environments.
- Print resolution: The narrowest bar (X-dimension) should be at least 0.33 mm (13 mils) for general-purpose scanning. Smaller X-dimensions require higher-resolution printing and more precise scanning equipment.
Production tips for barcode labels
- Test before mass printing: Always print a sample and verify it with the scanner model that will be used in production. Different scanners have different sensitivity and decoding capabilities.
- Avoid stretching or compressing: Barcodes should maintain their intended aspect ratio. Stretching horizontally can distort the bar-width ratios and cause decoding failures.
- Use bearer bars for ITF14: The ITF14 standard recommends a rectangular border (bearer bars) around the symbol to protect it during printing on corrugated cardboard, where ink spread can narrow the bars.
- Consider substrate color: If printing on colored material, ensure the background provides sufficient contrast. Translucent or glossy substrates can cause glare that interferes with scanning.
Limitations and cautions
- Browser-based rendering: This tool uses the JsBarcode library to render barcodes as SVG in the browser. The visual output depends on the browser's SVG rendering engine and may differ slightly from dedicated barcode printing software.
- No check digit calculation: The tool validates check digits for EAN13, EAN8, UPC, and ITF14, but does not calculate them automatically. You must provide the complete value including the final check digit.
- Educational scope: This page is intended for learning, testing, and quick label drafts. Production workflows should include verification with calibrated barcode verifiers that meet ISO/IEC 15416 requirements.
- Scanner compatibility: Not all barcode scanners support all symbologies. Verify that your target scanner supports the selected barcode type before printing labels at scale.
Final tips
- Start with CODE128 for maximum flexibility, as it supports the widest character set and is universally supported by modern scanners.
- For retail products, use EAN13 (outside North America) or UPC (North America) with a valid GS1 company prefix obtained from GS1.
- Always include a human-readable interpretation of the barcode data below the symbol for manual verification.
- Test barcode readability with the actual scanner hardware and lighting conditions that will be used in production.
- For pharmaceutical applications, ensure Pharmacode values fall within the 3–131070 range and are printed with sufficient contrast for high-speed scanning.