Barcode Generator
Generate barcodes in multiple formats online: CODE128, EAN13, EAN8, UPC, CODE39, ITF14
Enter content to generate a barcode
What is a Barcode?
A barcode is an encoding method that represents data using bars of different widths. It is widely used in product identification, logistics tracking, inventory management, and more. Common formats include CODE128 (universal), EAN-13 (international product code), and UPC (North American product code). Scanning barcodes enables quick data retrieval and improves work efficiency. Note: Barcodes can only encode ASCII characters (letters, numbers, and some symbols). They do not support non-ASCII characters like Chinese, Japanese, or Korean. Use the QR Code tool to encode Unicode text. Before publishing or submitting, open the output and check readability, cropping, resolution, ordering, and missing content.
How to Use
How to use
- Enter the content to encode (numbers or letters)
- Select the appropriate barcode format (different formats have different input requirements)
- Adjust bar width, height, color and other parameters
- Click the "Generate Barcode" button
- Download as PNG or SVG format
Barcode Checks
- Different barcode formats accept different character sets and lengths; validate content before printing labels.
- Print and scan a sample at the final size, especially when changing bar width, height, color, or quiet-zone spacing.
Use Cases
Technical Principle
Each symbology in this tool follows a published 1D bar specification: EAN-13 and UPC-A are defined by ISO/IEC 15420, Code 128 by ISO/IEC 15417, and Code 39 by ISO/IEC 16388. Every character is rendered as an alternating run of bars and spaces measured in multiples of the X-dimension (module width), typically 0.33 mm for retail EAN-13 at 100% magnification. EAN-13 packs 12 data digits plus a mod-10 check digit, encoded with three character sets (A/B/C) where the left-hand A/B parity pattern implicitly carries the 13th digit. Code 128 selects between sub-sets A, B, and C and uses sub-C to double-pack pairs of digits into a single 11-module symbol, which is why a long numeric SKU often comes out shorter than the same string in Code 39. The check digit for EAN/UPC is computed as (10 - (sum_odd * 3 + sum_even) mod 10) mod 10, with weights of 3 and 1 alternating from the right. Code 128 uses a different scheme: a weighted modulo-103 sum over the start character and data values. Drawing happens on an HTMLCanvasElement via fillRect for PNG export, and via concatenated SVG <rect> elements for the vector path; both targets honor the configured bar width, height, foreground/background, and the quiet-zone margin. Standards require a leading and trailing quiet zone of at least 10 X-dimensions for EAN/UPC (and 10 for Code 39), without which a scanner will refuse to decode even a perfectly drawn symbol. Unlike 2D codes such as QR, 1D symbologies carry no Reed-Solomon error correction, so a single damaged bar can desync the entire row; this is also why character sets are restricted (Code 39 to 43 chars, EAN/UPC to digits only) rather than full UTF-8. Real retail GTINs must still be assigned through a GS1 prefix; this tool only draws the bars and computes the checksum, it does not allocate company prefixes or guarantee uniqueness across the global GS1 registry.
- EAN-13 check digit: weights 1,3,1,3,... applied right-to-left, target sum is a multiple of 10.
- Code 128 uses sub-sets A/B/C with a mod-103 weighted check character; sub-C halves numeric width.
- Quiet zone must be at least 10 X-dimensions (about 3.3 mm at 100% EAN) on each side.
- Canvas rendering uses fillRect(x, 0, barWidth, height); SVG output emits one <rect> per dark module.
- No Reed-Solomon ECC in 1D codes - a single broken bar can void the scan, unlike QR with 7-30% recovery.
- ITF-14 requires bearer bars and a minimum bar height of 16 X-dimensions for reliable warehouse scanning.
- Code 39 allows 43 characters (0-9, A-Z, space, -.$/+%) plus mandatory * start/stop sentinels.
Examples
EAN-13 retail product
Format: EAN-13
Input: 4006381333931 (12 digits, the page appends the check digit)
Result: A 13-digit retail barcode. The first 3 digits (400-440)
are the GS1 prefix; the next 4-5 are the company prefix; then
the item reference; the trailing digit is the mod-10 check digit
computed from the first 12.
Quick check of the check digit: 3+0+6+8+1+3+3+9+3 = 36 (even
positions), 4+0+0+3+8+1+3+3+3+9+1 = 34 (odd positions) ->
3 * 36 + 34 = 142 -> (10 - 142 % 10) % 10 = 8, so the full
13-digit code is 40063813339318.CODE128 inventory label
Format: CODE128
Input: SKU-7842-AB
Result: A variable-width barcode that packs the entire ASCII
set by switching between sub-A (digits and control characters),
sub-B (printable ASCII), and sub-C (paired digits, half the
width). For this alphanumeric string the encoder picks sub-B
for the letters and symbols. CODE128 is the de-facto format for
internal SKUs and asset tags.ITF-14 carton label
Format: ITF-14
Input: 10012345678901 (14 digits)
Result: A logistics barcode used on shipping cartons. ITF-14
requires bearer bars (the solid bars that frame the symbol) and
a minimum bar height of 16 X-dimensions for reliable warehouse
scanning. The Interleaved 2 of 5 encoding pairs digits so the
symbol width per digit is half that of Code 39.FAQ
Which barcode formats can I generate?
Standard 1D codes: CODE 128 (general purpose, alphanumeric), CODE 39, EAN-13/EAN-8 (retail), UPC-A/UPC-E (US retail), ITF-14 (cartons). Some pages also include CODE 93 and Codabar. For 2D codes (QR, Data Matrix), use the dedicated QR Code generator tool.
What length and characters does each format allow?
EAN-13 needs exactly 12 numeric digits (the 13th is computed). EAN-8 needs 7. UPC-A needs 11. CODE 128 accepts variable-length ASCII (0-127), the most flexible choice for general use. CODE 39 supports digits, uppercase letters, and some symbols (-.$/+%). The page validates input before generating.
How is the check digit calculated?
EAN/UPC use Mod-10 with alternating ×1/×3 weights. ITF-14 uses Mod-10. CODE 128 uses a Mod-103 weighted-sum check character that is part of the symbol, not a separate digit. The generator computes them all automatically.
Is the barcode generated locally?
Yes. The barcode is rendered as SVG or canvas in your browser using JsBarcode or a similar library. No data is uploaded. You can save the result as PNG or SVG locally.
What size and resolution should I use for printing?
Retail 1D codes have an 'X-dimension' (the narrowest bar width) that should be at least 0.264 mm at 100% scale for reliable scanning. Print at 300 DPI or higher; lower-resolution thermal printers need bigger codes. Test-scan a printed sample with your actual scanner before mass producing.
Why does my scanner not read the printed code?
Common causes: code printed too small, low ink contrast, glossy/reflective surface, distortion from binding or curling, or wrong format for the scanner profile. Increase the X-dimension, print on matte paper, and ensure the surrounding 'quiet zone' (white margin) is at least 10× the X-dimension.
Can I add a logo or color to a 1D barcode?
1D barcodes need high contrast - black bars on white background is the only universally reliable choice. Adding a logo over the bars or using low-contrast colors will likely fail to scan. Stick to the standard look. QR codes have built-in error correction and can tolerate some logo overlay; 1D codes cannot.