Xerobit

Barcode Generator: Code 128, EAN, UPC, Code 39 and ITF

Enter your data and pick a format to generate a scannable barcode as an SVG image. This free barcode generator supports Code 128, Code 39, EAN-13, UPC-A, EAN-8 and ITF, computing check digits automatically. Everything runs in the browser so nothing is uploaded.

Result

Hello123
  • Format
    Code 128
  • Encoded data
    Hello123
  • Check digit
    44
  • Bar count
    34

How to use the barcode generator

  1. Enter the data you want to encode in the Data field.
  2. Select a barcode format from the dropdown, such as Code 128 or EAN-13.
  3. Adjust the bar height and toggle the human-readable text if needed.
  4. Click Generate to create the barcode as an SVG image.
  5. Copy the SVG code or download it for use on labels and packaging.

Supported barcode formats

This barcode generator handles six widely used symbologies. Code 128 encodes the full ASCII character set and uses automatic subset B and C switching for compact output. For dedicated tools, see the Code 128 barcode generator. Code 39 supports uppercase letters, digits and a few special characters; visit the Code 39 barcode generator for more detail.

EAN-13 is the global standard for retail products outside North America, encoding 13 digits including a computed check digit. UPC-A is its 12-digit counterpart used primarily in the United States and Canada. EAN-8 is a shortened version for small packages where a full EAN-13 symbol would not fit. ITF (Interleaved 2 of 5) encodes pairs of digits into interleaved bars and spaces, commonly printed on corrugated cardboard shipping cartons.

How check digits are calculated

EAN-13, UPC-A and EAN-8 all use the same modulo 10 check digit algorithm. Starting from the rightmost data digit (excluding the check digit position), alternate multiplying by 3 and 1, sum the results, then subtract the sum modulo 10 from 10.

For example, the first 12 digits of an EAN-13 code might be 400638133393. The weighted sum is computed as follows:

Position (from right)DigitWeightProduct
1339
2919
3339
4313
5339
6111
78324
8313
96318
10010
11030
12414

The total is 89. Since 89 mod 10 equals 9, the check digit is 10 minus 9, which gives 1. The complete EAN-13 number is therefore 4006381333931.

Code 128 uses a different scheme: each character value is multiplied by its position index, summed with the start code value, and reduced modulo 103. Code 39 optionally appends a modulo 43 check character.

EAN and UPC encoding tables

EAN-13, UPC-A and EAN-8 represent each digit as a pattern of 7 modules (bars and spaces). Three encoding sets exist: L (odd parity), G (even parity) and R (right side). The first digit of an EAN-13 number selects a parity pattern that determines whether each of the next six digits uses L or G encoding.

First digitParity pattern (positions 2 to 7)
0L L L L L L
1L L G L G G
2L L G G L G
3L L G G G L
4L G L L G G
5L G G L L G
6L G G G L L
7L G L G L G
8L G L G G L
9L G G L G L

The left guard is always 101, the centre guard is 01010 and the right guard is 101. UPC-A treats the number system digit as part of the left side without a separate parity table, effectively using the pattern for first digit 0.

Quiet zones and print requirements

Every barcode needs a quiet zone: blank space on both sides that tells the scanner where the symbol begins and ends. This tool adds 10 modules of quiet zone on each side, matching common specifications. EAN-13 technically requires 11 modules on the left and 7 on the right, but 10 modules works reliably for most scanners and keeps the SVG layout consistent across formats.

Bars must be dark on a light background for optical scanners to read them correctly. The default white background ensures maximum contrast. If you choose transparent, make sure the surface behind the barcode is light-coloured when printed. A minimum bar width (X dimension) of 0.33 mm is typical for retail EAN and UPC symbols at 100 percent magnification.

Common mistakes to avoid

Supplying too many or too few digits is the most frequent error with numeric formats. Enter 12 digits for UPC-A, 12 or 13 for EAN-13, and 7 or 8 for EAN-8. The tool computes or validates the check digit automatically, but providing the wrong length will produce an error.

Code 39 only accepts uppercase letters, digits, hyphens, periods, spaces, dollar signs, slashes, plus signs and percent signs. Lowercase input is converted automatically, but other characters will be rejected. ITF requires an even number of digits; this tool prepends a zero if you enter an odd count, but it is better practice to supply the correct length yourself.

When embedding the generated SVG in HTML, ensure the container does not scale the image below the minimum readable size. Scanners need sufficient resolution to distinguish individual modules.

Worked examples

Each result below was produced by the same code the tool runs, so you can check your own numbers against them.

ExampleInputResult
Code 128 greetingData: Hello123; Format: code128; Bar height (px): 80; Show human-readable text: yes; Background: whiteFormat: Code 128; Encoded data: Hello123; Check digit: 44; Bar count: 34
EAN-13 productData: 400638133393; Format: ean13; Bar height (px): 80; Show human-readable text: yes; Background: whiteFormat: EAN-13; Encoded data: 4006381333931; Check digit: 1; Bar count: 30
UPC-A retailData: 03600029145; Format: upca; Bar height (px): 80; Show human-readable text: yes; Background: whiteFormat: UPC-A; Encoded data: 036000291458; Check digit: 8; Bar count: 30
Code 39 labelData: WIKI; Format: code39; Bar height (px): 60; Show human-readable text: yes; Background: whiteFormat: Code 39; Encoded data: *WIKI*; Check digit: None; Bar count: 30

FAQ

Is this barcode generator free to use?

Yes, it is completely free. You can generate unlimited barcodes in any supported format without creating an account or paying a fee.

Do I need to calculate the check digit myself?

No. For EAN-13, UPC-A, EAN-8, Code 128 and Code 39, the tool computes the check digit automatically. You can also enter the full number including the check digit and it will be validated.

Can I use these barcodes on physical products?

Yes, provided you have been assigned valid GS1 company prefixes for EAN or UPC numbers. The SVG output is suitable for printing on labels and packaging.

What is the difference between Code 128 and Code 39?

Code 128 is denser and supports the full ASCII character set, making it ideal for logistics and inventory. Code 39 is simpler, supports a smaller character set, and is widely used in industrial labeling. Dedicated pages exist for the code 128 barcode generator and code 39 barcode generator.

Why does my scanner fail to read the barcode?

Ensure the barcode is printed at a sufficient size with high contrast. Bars must be black on a white or very light background. Check that quiet zones are not clipped and that the printer resolution is at least 300 DPI.

Does this tool upload my data to a server?

No. All encoding happens locally in your browser. Nothing is transmitted over the network, keeping your data private.