A test barcode number is a UPC, EAN or ISBN with a correct check digit that is not tied to a product you sell. This generator produces UPC-A, EAN-13, EAN-8, ISBN-13 and ISBN-10 numbers with the check digit computed, plus internal SKUs and ten-character ASIN-style codes — the identifiers a catalogue, POS system or inventory import has to validate.
How to use it
- Pick a standard. UPC-A and EAN-13 cover most retail; ISBN for books; EAN-8 for small packaging.
- Optionally enter a company prefix. Use
20–29on EAN-13, or2or4on UPC-A, for numbers that can never identify a real trade item. - Toggle ISBN hyphens and the separate check-digit column if your tests need them.
- Copy or export the batch. Feed it to a barcode renderer, or use the QR & barcode placeholder generator for images.
What you can control
- UPC-A (12 digits), EAN-13 (13), EAN-8 (8), ISBN-13 (978 or 979 prefix) and ISBN-10, each with a correct check digit.
- A company prefix of your choosing, including GS1 restricted-circulation ranges.
- Hyphenated or compact ISBNs.
- A separate check-digit column for testing validators digit by digit.
- Internal SKUs (
ABC-12345-67) and ASIN-style codes (B0plus eight alphanumerics).
How the GTIN check digit works
Take the EAN-13 400638133393?. From the left, multiply the twelve digits alternately by 1 and 3 (equivalently, from the right by 3 and 1):
| Digit | 4 | 0 | 0 | 6 | 3 | 8 | 1 | 3 | 3 | 3 | 9 | 3 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Weight | 1 | 3 | 1 | 3 | 1 | 3 | 1 | 3 | 1 | 3 | 1 | 3 |
| Product | 4 | 0 | 0 | 18 | 3 | 24 | 1 | 9 | 3 | 9 | 9 | 9 |
The products total 89. The next multiple of ten is 90, so the check digit is 1: 4006381333931.
function gtinCheckDigit(body) {
const sum = [...body].reverse().reduce((acc, d, i) => acc + Number(d) * (i % 2 === 0 ? 3 : 1), 0);
return (10 - (sum % 10)) % 10;
}
gtinCheckDigit("400638133393"); // 1
Weighting from the right is what lets one function handle every GTIN length: the digit beside the check digit always gets weight 3.
Testing ideas
- Leading zeros. UPCs and EANs can start with
0. Store one as an integer and it loses a digit and its check digit becomes wrong. Generate UPC-A codes with prefix0and round-trip them through your database. - UPC to EAN normalisation. Check that
036000291452and0036000291452resolve to the same product. - ISBN-10 with X. Generate ISBN-10s until one ends in
X, and confirm your field does not reject the letter or lowercase it. - Scanner input. Hardware scanners type the code and press Enter. Paste a code followed by a newline into your search field to simulate it.
What this is not
A correct check digit does not make a barcode yours. Retail barcodes must be licensed from GS1; ISBNs from your national ISBN agency. Use these for software testing, and use a restricted-circulation prefix whenever a number might end up printed.