Barcode Generator (Code 128, EAN-13, UPC-A, EAN-8, Code 39)
Choose a barcode type, type the number or text and the barcode appears at once, with the check digit worked out for you and nothing uploaded. The example 4006381333931 is the 12 digits 400638133393 plus the check digit 1: an EAN-13 of 95 modules with quiet zones of 11 and 7 modules, drawn 4 pixels per module as 452 × 174 px. Download it as a PNG at your size and DPI, or as a scalable SVG, or copy the SVG. The encoders are written for this site to ISO/IEC 15417 (Code 128), the GS1 General Specifications (EAN and UPC) and ISO/IEC 16388 (Code 39).
Updated Runs in your browser: nothing you enter is uploadedHow this tool works
What should the barcode say?
Your barcode
- Type
- EAN-13
- Number
- 4006381333931
- Check digit
- 1 (verified, GS1 modulo 10)
- Left-hand digits use
- L G L L G G (odd/even parity)
- Width
- 95 modules plus 11 and 7 quiet zone
- Image
- 452 × 174 px, 4 px per module
- Printed at 300 DPI
- 1.51 in × 0.58 in (38.27 mm × 14.73 mm), module 0.34 mm
Made on your device: nothing you type is uploaded, saved or put in the address of this page.
The five barcode types
| Type | Holds | Check | Example | Width | Quiet zone (left, right) |
|---|---|---|---|---|---|
| Code 128 | ASCII text, digits packed in pairs | Modulo 103 symbol | PJJ123C | 112 modules | 10 and 10 modules |
| EAN-13 | 13 digits | GS1 digit | 4006381333931 | 95 modules | 11 and 7 modules |
| UPC-A | 12 digits | GS1 digit | 036000291452 | 95 modules | 9 and 9 modules |
| EAN-8 | 8 digits | GS1 digit | 73513537 | 67 modules | 7 and 7 modules |
| Code 39 | 0-9, A-Z, space and - . $ / + % | Optional modulo 43 | CODE39 | 127 modules | 10 and 10 modules |
How the check digit of 4006381333931 is worked out
| Position | Digit | Weight | Product |
|---|---|---|---|
| 1 | 4 | 1 | 4 |
| 2 | 0 | 3 | 0 |
| 3 | 0 | 1 | 0 |
| 4 | 6 | 3 | 18 |
| 5 | 3 | 1 | 3 |
| 6 | 8 | 3 | 24 |
| 7 | 1 | 1 | 1 |
| 8 | 3 | 3 | 9 |
| 9 | 3 | 1 | 3 |
| 10 | 3 | 3 | 9 |
| 11 | 9 | 1 | 9 |
| 12 | 3 | 3 | 9 |
EAN-13 left half: which digits use odd or even parity
| First digit | Parity of the six left-hand digits |
|---|---|
| 0 | L L L L L L |
| 1 | L L G L G G |
| 2 | L L G G L G |
| 3 | L L G G G L |
| 4 | L G L L G G |
| 5 | L G G L L G |
| 6 | L G G G L L |
| 7 | L G L G L G |
| 8 | L G L G G L |
| 9 | L G G L G L |
Code 128 character sets
| Set | Characters | Start value | Best for |
|---|---|---|---|
| A | Digits, capitals, control codes (ASCII 0-95) | 103 | Capital letters and control characters |
| B | Digits, capitals, lowercase, punctuation (ASCII 32-127) | 104 | General text |
| C | Pairs of digits 00 to 99 | 105 | Long numbers, at half the width |
Code 39 characters in value order
| Values | Characters |
|---|---|
| 0 to 9 | 0 1 2 3 4 5 6 7 8 9 |
| 10 to 19 | A B C D E F G H I J |
| 20 to 29 | K L M N O P Q R S T |
| 30 to 39 | U V W X Y Z - . space $ |
| 40 to 42 | / + % |
Sizes the tool warns about
| Module width | DPI | One module | Within GS1 range? |
|---|---|---|---|
| 2 px | 300 | 0.169 mm | No, too small |
| 3 px | 300 | 0.254 mm | No, too small |
| 4 px | 300 | 0.339 mm | Yes |
| 4 px | 600 | 0.169 mm | No, too small |
| 8 px | 300 | 0.677 mm | No, too large |
How to make a barcode
- Choose the type and enter the data. Pick Code 128, EAN-13, UPC-A, EAN-8 or Code 39 and type the number or text. For EAN and UPC you can leave the check digit off (the tool adds it) or include it (the tool checks it and shows the correct digit if it is wrong). Spaces and hyphens in the number are ignored.
- Set the module width, height and DPI. Module width is the number of pixels in the narrowest bar. Bar height is in pixels. DPI decides the printed size shown under the barcode and is saved in the PNG. For retail EAN or UPC, aim for a module of about 0.33 mm: 4 pixels at 300 DPI is 0.34 mm.
- Download or copy it. Download PNG for documents and labels, Download SVG for print and anything that must stay sharp at any size, or copy the SVG markup into a design file. Print a test sheet and scan it before you print many.
Frequently asked questions
- Is this barcode generator free, and is my data sent anywhere?
- It is free and runs entirely in your browser. The barcode is calculated on your device by code that ships with this page, so the numbers and text you type are never uploaded or saved.
- Which barcode type should I use?
- Use EAN-13 (or UPC-A in the US and Canada) for products sold in shops: the number must be a registered GS1 number. Use Code 128 for shipping labels, inventory, tickets and any text: it is compact and holds all of ASCII. Use Code 39 when a system or standard asks for it, as in badges, some automotive and government uses. EAN-8 is for packages too small for an EAN-13.
- What is the check digit and how is it calculated?
- The check digit catches a mistyped or misread digit. For EAN-13, UPC-A and EAN-8, the digits are weighted 3, 1, 3, 1 from the right, added, and the check digit brings the total up to a multiple of 10. For 400638133393 the sum is 89, so the check digit is 1 and the number is 4006381333931. Code 128 has a check symbol (a weighted sum modulo 103, added automatically), and Code 39's check character is optional.
- What happens if the check digit I typed is wrong?
- The tool does not draw a barcode with a wrong check digit. It shows the correct one instead: Check digit mismatch: the last digit is 2 but the correct check digit for 400638133393 is 1, which makes 4006381333931.
- Do I get a real, registered product barcode from this?
- No. This tool draws the symbol for a number you supply. The company prefix inside an EAN or UPC number is licensed by GS1, and shops and marketplaces check that the number belongs to you. Get your numbers from GS1 in your country; then use this tool to draw them.
- What is a quiet zone, and why does it matter?
- The quiet zone is the empty margin on each side that tells a scanner where the barcode starts and ends. This tool always includes it: 11 and 7 modules for EAN-13, 9 and 9 modules for UPC-A, 7 and 7 modules for EAN-8 and 10 modules for Code 128 and Code 39. If you place the image on a coloured background or crop it, keep that margin clear.
- How does Code 128 choose between its code sets?
- Code 128 has three character sets: A (capitals and control codes), B (upper and lowercase) and C (pairs of digits). The tool finds the sequence with the fewest symbol characters, switching sets where it saves space and using a single-character shift for one control code in lowercase text. A run of digits is packed in pairs in set C, half the width. For PJJ123C the check symbol is 54.
- What module width, height and DPI should I choose?
- The module width is how many pixels the thinnest bar is; the DPI says how big a pixel is on paper. Their ratio is the physical module size. Retail EAN and UPC use about 0.33 mm, within 0.264 to 0.66 mm. For other barcodes a module of 0.25 mm or more is typical for office and label printers. Bars should be tall: a height of at least 15% of the barcode width is typical for Code 128 and Code 39.
- Should I download PNG or SVG?
- PNG is a grid of pixels at exactly the size you chose, with the DPI saved in the file, which suits documents and label software. SVG is vector, so it stays sharp at any size and is the better choice for print; its width and height are set in inches from your DPI. Copy SVG puts the markup on the clipboard to paste into a design tool or web page.
- Are the encoders correct?
- Each encoder is written from the standards: Code 128 with the 107 bar/space patterns, automatic code set selection and the modulo 103 check symbol; EAN-13, UPC-A and EAN-8 with the L, G and R digit codes, the parity table and GS1 check digit; Code 39 with its 43 patterns and the optional modulo 43 check. The tests check the pattern tables against the ZXing reference decoder data, the GS1 example 4006381333931, the Code 128 worked example PJJ123C, and read generated symbols back with an independent decoder. Code 128 FNC characters (GS1-128), add-on digits (EAN-2 and EAN-5) and UPC-E are not supported.
How it works
Each type becomes a string of modules, 1 for a bar and 0 for a space. For EAN-13 the number is checked (or its 13th digit computed) and drawn as a 3-module start guard, six left digits of 7 modules each, a 5-module centre guard, six right digits and an end guard: 95 modules. The first digit selects which left digits use the odd (L) or even (G) set. UPC-A is drawn as an EAN-13 with a leading 0, and EAN-8 as four left and four right digits (67 modules). Code 128 starts with a start character that names the first set, then data symbols of 11 modules each, the check symbol (the start value plus each value times its position, modulo 103), and the 13-module stop pattern 2331112. The set sequence is the shortest one, found by dynamic programming over the position and the current set. Code 39 draws each character as nine elements (three wide, each wide element 3 modules), separated by a one-module space, with * at both ends. The drawing is laid out in whole pixels per module, so edges stay sharp: quiet zones left and right, a small margin above and below, bars of the height you chose (EAN and UPC guards run longer) and the human-readable text under them. SVG and PNG come from the same layout. The PNG gets a pHYs chunk with your DPI. Everything runs in your browser; nothing you enter is sent anywhere.
Sources
- GS1 General Specifications (EAN/UPC symbol structure, check digit calculation, quiet zones and X-dimension)
- ISO/IEC 15417, Information technology: Automatic identification and data capture techniques: Code 128 bar code symbology specification
- ISO/IEC 16388, Information technology: Automatic identification and data capture techniques: Code 39 bar code symbology specification
- ZXing: Code128Reader, Code39Reader and UPCEANReader (reference pattern tables used in the tests)
More free tools
- QR Code GeneratorTurn a link, text, Wi-Fi login, email or phone into a QR code. Set error correction, size and colors, then download PNG or SVG. Made on your device.
- UUID GeneratorGenerate random v4 and time-ordered v7 UUIDs on your device, up to 1,000 at a time, and inspect any UUID for its version, variant and embedded timestamp.
- Text to Binary ConverterConvert text to binary, hex, octal or decimal bytes and back. UTF-8 by default (é is 2 bytes, an emoji 4) or UTF-16, with a per-character breakdown.
- Image ResizerResize and compress JPEG, PNG and WebP images by width, height, percent or longest side, and convert the format. Runs in your browser; nothing is uploaded.
- Word CounterCount words, characters, sentences and reading time, and check your text against X, LinkedIn, Instagram, SMS and meta description limits.
- Case ConverterConvert text to UPPERCASE, lowercase, Title Case, Sentence case, camelCase, PascalCase, snake_case, kebab-case or CONSTANT_CASE. Stays in your browser.