1001Ferramentas
πŸ“ŠValidators

EAN-13 Validator

Validate EAN-13 (13-digit) retail barcode.

EAN-13 validation: how the retail barcode actually checks out

An EAN-13 (European Article Number, 13 digits) is the most common product barcode on the planet β€” every box of cereal, every shampoo bottle, every paperback book carries one on its back. The standard is published as ISO/IEC 15420 and the numbering scheme is governed by GS1, the global non-profit that allocates country prefixes and registrant numbers. Validating an EAN-13 means proving three things: the length is exactly 13 digits, every character is 0-9, and the last digit matches the mod-10 check computed from the first twelve.

This page runs the arithmetic in your browser, but a complete production check also looks up the leading 2-3 digits in the GS1 prefix table to make sure they belong to a real registered country/economy. A barcode like 1234567890128 passes the math but begins with 1, which GS1 has never allocated β€” so a strict validator should flag it as suspicious even though the check digit is correct.

Anatomy of an EAN-13

The 13 positions are split into GS1 prefix (1-3 digits, country or economy), company / registrant (variable length, allocated by the national GS1 office), product reference (whatever digits remain) and one check digit. The cut between registrant and product is private β€” only the company that owns the prefix knows it β€” which is why validators never try to parse that boundary.

  • 789, 790 β€” Brazil (allocated by GS1 Brasil).
  • 30-37 β€” France.
  • 400-440 β€” Germany.
  • 50 β€” United Kingdom.
  • 489 β€” Hong Kong.
  • 690-699 β€” Mainland China.
  • 880 β€” South Korea.
  • 978-979 β€” Bookland (used by ISBN-13).
  • 977 β€” Periodicals (used by ISSN).

The mod-10 check-digit algorithm

Take positions 1 through 12 from left to right. Multiply each by an alternating weight pattern 1, 3, 1, 3, … β€” position 1 gets weight 1, position 2 gets weight 3, position 3 gets weight 1, and so on. Sum the twelve products, take the remainder modulo 10, and the check digit is (10 - remainder) mod 10. The outer mod 10 covers the edge case where the remainder is 0, which would otherwise yield a DV of 10 (illegal).

// 5901234123457 β€” Polish soft drink
digits = [5,9,0,1,2,3,4,1,2,3,4,5]
sum    = 5*1 + 9*3 + 0*1 + 1*3 + 2*1 + 3*3
       + 4*1 + 1*3 + 2*1 + 3*3 + 4*1 + 5*3
       = 5+27+0+3+2+9+4+3+2+9+4+15 = 83
dv     = (10 - 83 % 10) % 10 = (10 - 3) % 10 = 7
// EAN-13: 5901234123457

Note that the very same algorithm validates ISBN-13 (because every ISBN-13 is a Bookland EAN-13 with prefix 978/979) and GTIN-13, the umbrella product identifier maintained by GS1.

EAN-13 vs UPC-A, UPC-E, EAN-8, ITF-14

The 12-digit UPC-A used in North America is a strict subset of EAN-13 β€” drop the leading zero and you get UPC-A; prepend a zero and you turn UPC-A into EAN-13. Most modern PoS scanners read both transparently. UPC-E is a compressed 8-digit form for small US products that expands back to UPC-A by inserting zeros. EAN-8 is the European equivalent of UPC-E and is governed by a separate (smaller) GS1 allocation β€” see our EAN-8 validator. ITF-14 wraps an EAN-13 inside a logistic shipping container (master case) by prefixing an indicator digit and recomputing the DV.

Brazilian retail context: GS1 Brasil and the marketplaces

In Brazil, GS1 Brasil (gs1br.org) is the only entity authorised to allocate 789 and 790 prefixes. Membership starts around R$ 2.000 per year and scales with the number of SKUs. Mercado Livre requires a valid EAN/GTIN on every Buy Box listing and rejects sellers who reuse competitors' codes. Magazine Luiza, Amazon.com.br, Shopee BR and Americanas apply the same rule. The supermarket checkout chains β€” Carrefour, PΓ£o de AΓ§ΓΊcar, AssaΓ­ β€” block PLU entry when the EAN check fails. Internally, ERPs such as SAP, TOTVS Protheus and Bling all bundle EAN-13 validation in their item-master modules.

Anti-fraud and common pitfalls

  • Wrong prefix: a "valid" EAN with prefix 140 or 200-299 (in-store / coupon namespace) is suspicious for cross-marketplace listing.
  • Cloned codes: a registrant cannot legally reuse another company's EAN β€” Mercado Livre cross-checks against the GS1 GEPIR database.
  • Leading-zero confusion: a UPC-A that arrives as 12 digits should be left-padded with 0 before passing through an EAN-13 validator.
  • Image OCR: zero vs O and one vs lowercase l are the classic substitutions; the mod-10 weighting catches single-digit errors but not adjacent-digit transpositions where the two digits differ by 5.
  • Generation libraries: JsBarcode, bwip-js and python-barcode all produce printable EAN-13 SVG/PNG once you supply a registered body.

FAQ

Is EAN-13 the same as UPC-A? Almost. UPC-A is the 12-digit North American flavour; EAN-13 is the international 13-digit superset β€” UPC-A is exactly EAN-13 with a leading zero.

Is an EAN mandatory in Brazilian retail? Yes for any product sold through Mercado Livre, Magazine Luiza, Amazon.com.br, supermarkets and most physical chains β€” they refuse to onboard SKUs without it.

How much does GS1 Brasil membership cost? Plans start around R$ 2.000/year and grow with the number of allocated codes; check gs1br.org for the current tier table.

Can I make up my own EAN? Technically yes for purely internal use (the in-store 2xx namespace exists for that), but external marketplaces will reject it. Always buy a real prefix from GS1.

Does a valid check digit prove the product exists? No. The math only proves the number is internally consistent. To confirm registration, query GS1 GEPIR or the marketplace catalogue.

Related Tools