How to use the EAN-13 generator
- Choose the Mode: Generate test values or Validate or complete.
- To generate, choose a Prefix: 20–29: restricted circulation (in-store use; safe for tests) or Any prefix (may collide with real products). Set How many (up to 500) and press Generate.
- To check a number, type it into EAN-13 (or the first 12 digits to get the check digit). Spaces and dashes are ignored.
- With 12 digits you get the Check digit and the Full EAN-13. With 13 digits you get Result, Check digit given and Check digit expected.
What it does and when to use it
EAN-13 is the barcode number on most retail products outside North America. Point-of-sale systems, stock apps and online shops all check its last digit. Developers and testers need valid numbers to fill product tables and test scanners without using someone else’s real product codes. Shop owners sometimes need a quick check digit when they label their own items for in-store use.
The validator catches typing mistakes, because changing any single digit changes the check digit. For the shorter code on small packs, see the EAN-8 generator. For the 12-digit North American version, use the UPC-A generator. For internal stock codes without a barcode standard, the serial number generator may suit you better.
How it works
The check digit uses the GS1 mod-10 method:
- Take the first 12 digits. Counting from the left, multiply digits in odd positions by 1 and in even positions by 3.
- Add the results.
- The check digit is the amount needed to reach the next multiple of 10 (0 if the sum already is one).
For generated numbers, the first two digits come from 20–29 (or anything, with Any prefix), the other ten are random from crypto.getRandomValues, and the check digit is added.
Worked examples
- A real product code.
4006381333931givesResult: Valid. For the first 12 digits, 4×1 + 0×3 + 0×1 + 6×3 + 3×1 + 8×3 + 1×1 + 3×3 + 3×1 + 3×3 + 9×1 + 3×3 = 89, and 90 − 89 = 1, the last digit. - Completing a number. Typing
590123412345returnsCheck digit: 7andFull EAN-13: 5901234123457. - A typo.
4006381333932givesResult: InvalidwithCheck digit expected: 1. - Test numbers. One run gave
2366010546814and2933776035434, followed by the note “Test values only: they pass the check-digit rules but are random…”.
Limits and tips
- A valid check digit does not mean the product exists. Only GS1’s registry can tell you who owns a number.
- Numbers of the wrong length get a short message, such as “An EAN-13 has 13 characters; this has 8.”
- Some shops encode price or weight inside 20–29 numbers. Check your till system’s rules before using them in-store.
Frequently asked questions
Can I print these numbers on products I sell?
Why do the test numbers start with 20 to 29?
How do I turn the number into a barcode image?
Is an EAN the same as a GTIN-13?
How do we know nothing is uploaded? Test it yourself on the privacy proof page.