# 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).

Canonical page: https://ponderloop.com/tools/barcode-generator/
Updated: 2026-10-18

## How to use

How to make a barcode

1. **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.
2. **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.
3. **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.

## Reference tables and worked examples

### The five barcode types

What each type holds and how wide it is for the examples used here. Widths count modules (the narrowest bar); the quiet zone is the empty margin the standard asks for on each side.

| 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

Working from the right, the digits are multiplied by 3, 1, 3, 1 and so on and added: the sum is 89. The check digit is what makes the total a multiple of 10: (10 − 89 mod 10) mod 10 = 1. The same rule gives the last digit of EAN-8, UPC-A and EAN-13.

| 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

EAN-13 has 13 digits but only 12 are drawn as digit codes: the first digit is hidden in which of the six left-hand digits use the L (odd parity) or G (even parity) codes. UPC-A is the same symbol with a first digit of 0 (all L).

| 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

A single Code 128 symbol can switch between three sets. The tool picks the sequence with the fewest symbols: for example PJJ123C needs 8 symbols plus the check and stop in set A, while 12345678 is 4 pairs in set C after the start character.

| 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

The 43 characters in the order used for the optional check character: add the values of the data characters and take the remainder after dividing by 43. CODE39 adds up to the check character W, giving CODE39W.

| 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

GS1 sizes retail EAN and UPC symbols from 80% to 200% of a nominal module of 0.33 mm. The tool shows one module in millimetres at your DPI and warns outside that range.

| 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 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.

## FAQ

### 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.

## Sources

- [GS1 General Specifications (EAN/UPC symbol structure, check digit calculation, quiet zones and X-dimension)](https://www.gs1.org/standards/barcodes-epcrfid-id-keys/gs1-general-specifications)
- 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](https://www.iso.org/standard/43897.html)
- [ZXing: Code128Reader, Code39Reader and UPCEANReader (reference pattern tables used in the tests)](https://github.com/zxing/zxing/tree/master/core/src/main/java/com/google/zxing/oned)

---

Cite as: Barcode Generator (Code 128, EAN-13, UPC-A, EAN-8, Code 39), ponderloop, https://ponderloop.com/tools/barcode-generator/, updated 2026-10-18
