Online Barcode Generator

Generate CODE128, CODE39, EAN13, EAN8, UPC, ITF14, MSI, and Pharmacode barcodes with validation, color control, live preview, and PNG download.

Tool

Barcode Generator

Create CODE128, CODE39, EAN13, EAN8, UPC, ITF14, MSI, and Pharmacode barcodes with customizable colors, optional description text, live preview, and PNG download.

Enter barcode data, select a barcode type, choose colors, and press Generate to preview the barcode.

Barcode data

Preview

Barcode Generation Results

Barcode Type
Barcode Data
Description
Code Color
Background Color

These results are for reference only and were developed for educational and testing purposes. You can also directly access and review the source code, including the logic and free libraries used on this page.

Overview

What this generator does

This browser-based barcode generator creates common 1D barcode formats for testing, labeling drafts, inventory examples, retail data checks, and learning. It validates the selected format before rendering, shows the output immediately, and can download the result as a PNG image.

EAN13, EAN8, UPC, and ITF14 require full numeric values including valid check digits. Pharmacode accepts only numeric values from 3 to 131070. For production labels, always test print size, contrast, quiet zones, scanner behavior, and industry compliance requirements.

How To

How to use the Barcode Generator

  1. 1

    Select a barcode type

    Choose the barcode format that fits your task, such as CODE128 for flexible encoding, EAN13 for retail products, or Pharmacode for pharmaceutical workflows.

  2. 2

    Enter barcode data

    Type or paste the value you want to encode. Make sure the length and character set match the selected barcode standard.

  3. 3

    Add an optional description

    You can place a short note below the barcode to identify the item, product, location, or use case more clearly.

  4. 4

    Choose barcode colors

    Select the code color and background color. High contrast combinations such as black on white usually scan more reliably.

  5. 5

    Generate and review

    Press Generate to validate the input, render the barcode preview, and display the selected settings in the result panel.

  6. 6

    Download or reset

    Download the generated barcode as a PNG image, or use Clear to reset the text, description, preview, colors, and validation messages.

Guide

Detailed guide to barcode generation: symbologies, encoding principles, and best practices

Thumbnail image for the barcode generator.

How to use the Barcode Generator

Follow these steps to create a barcode suited to retail, inventory, logistics, healthcare, or testing workflows:

  1. 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.
  2. 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.
  3. Add Description: Optionally enter a short label or note that appears below the barcode in the preview and in the downloaded PNG output.
  4. 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.
  5. 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.
  6. 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

  1. Start with CODE128 for maximum flexibility, as it supports the widest character set and is universally supported by modern scanners.
  2. For retail products, use EAN13 (outside North America) or UPC (North America) with a valid GS1 company prefix obtained from GS1.
  3. Always include a human-readable interpretation of the barcode data below the symbol for manual verification.
  4. Test barcode readability with the actual scanner hardware and lighting conditions that will be used in production.
  5. For pharmaceutical applications, ensure Pharmacode values fall within the 3–131070 range and are printed with sufficient contrast for high-speed scanning.
A practical starting point is CODE128 with black code color, white background, and a short description only if you need printed identification below the symbol. For authoritative reference, consult the GS1 General Specifications, the ISO/IEC 15416 standard, and the GS1 check digit calculator.

FAQ

Frequently asked questions

Does this tool calculate missing check digits automatically?

No. Enter the full value including the final check digit for EAN13, EAN8, UPC, and ITF14. The page validates the digit you provide.

Can I use custom colors for the barcode?

Yes. You can change both the code color and the background color. For dependable scanning, choose a strong contrast combination such as black on white.

What barcode types are available?

The tool supports CODE128, CODE39, EAN13, EAN8, UPC, ITF14, MSI, and Pharmacode.

Is this page suitable for production labels?

This page is intended for educational and testing purposes. Production workflows should include printer calibration, size checks, barcode verification, and scanner testing in the real target environment.