# GTIN validator: check digit, length and prefix

> Check your GTIN, EAN and UPC codes: the GS1 check digit, the length, and whether the prefix is restricted circulation, a book or a coupon.

URL: https://clione.ai/tools/gtin-validator/
Lang: en

A [GTIN](/glossary/gtin/) is the number that identifies a product in trade: the one encoded in the [EAN](/glossary/ean-code/) and UPC barcodes on the package. This validator checks it on three things you can know without asking anyone: the length, the check digit and the prefix. It's for anyone who runs a store, or runs one for a client from an agency, and is about to publish those codes on their product pages, in a [product feed](/glossary/product-feed/) or in their [structured data](/glossary/structured-data/): a code with one digit missing or one digit wrong doesn't show on the page, and it leaves the product with an identifier that identifies nothing.

The validator runs in your browser. It doesn't look anything up in a database, and what you paste doesn't leave the page. That's why it can tell you whether a code is well formed, but not whose it is (more on that below).

## How to use it

1. **Pull the codes from your catalog**, for example the barcode column of a product export.
2. **Paste them into the box, one per line**, up to 500. Spaces and dashes are ignored: `952 1234 567899` and `952-1234567899` read the same.
3. **Press Check.** "Load an example" fills the box with six cases: a valid code, the same code with the last digit wrong, a textbook UPC-A, a book, a restricted circulation number and a code one digit short.
4. **Read one row per code.**

## How to read the result

The table has four columns: the code as you pasted it, its length, the verdict and the result.

**The verdict** comes in three forms. "Valid" marked as correct: the length and the check digit are right. "Valid" marked as a warning: the code is well formed, but its prefix is restricted circulation and it shouldn't be published as a GTIN. "Invalid": something is wrong, and the result says what.

**The result** gathers what the validator found:

- "Only digits are allowed." The code has letters or other characters.
- "11 digits: a GTIN has 8, 12, 13 or 14." The length is none of the four.
- "All zeros is not a GTIN."
- "The check digit is 4 and should be 5." The last digit doesn't match the others.
- What the prefix says, such as "A book (ISBN): publish it as isbn."
- The [Schema.org](/glossary/schema-org/) property that fits it, such as "Schema.org property: gtin13". It doesn't appear for invalid codes or for restricted circulation numbers.

## The check digit, step by step

The last digit of a GTIN is a check digit: it's calculated from the others to confirm the number is put together correctly.[^gs1-calculator] GS1's method has three steps.[^gs1-check-digit]

1. Multiply each digit by 3 or by 1, alternating, starting with **the digit just to the left of the check digit, which gets 3**.
2. Add up the results.
3. Subtract that sum from the nearest multiple of ten equal to or above it. What's left is the check digit.

Here's an example with a number from prefix 952, which GS1 reserves for demonstrations and examples of its system.[^gs1-prefix] We want the check digit for the first twelve digits of a GTIN-13, `952123456789`:

| Digit  | 9   | 5   | 2   | 1   | 2   | 3   | 4   | 5   | 6   | 7   | 8   | 9   |
| ------ | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| Weight | 1   | 3   | 1   | 3   | 1   | 3   | 1   | 3   | 1   | 3   | 1   | 3   |
| Result | 9   | 15  | 2   | 3   | 2   | 9   | 4   | 15  | 6   | 21  | 8   | 27  |

The sum is 121. The nearest multiple of ten at or above it is 130, and 130 minus 121 is 9. **The full GTIN-13 is `9521234567899`.**

Run it through the validator and it will pass. Now try two typical mistakes made when copying a code:

- **One digit changed.** `9521234567896` ends in 6: the validator says the check digit is 6 and should be 9.
- **Two digits swapped.** `9521234567989` swaps the 8 and the 9 near the end: the validator says the check digit is 9 and should be 1.

And one that isn't a copying mistake but a length mistake: `952123456789`, the same twelve digits without the check digit, is read as a GTIN-12 whose last digit, the 9, would be the check digit, and it should be 6. **One digit more or less is not the same code**.

## What the prefix says, and what it doesn't

The first digits of a GTIN are the GS1 prefix. **The prefix doesn't say where the product was made**: GS1 points this out, because a company can manufacture anywhere in the world.[^gs1-prefix] Country prefixes belong to the GS1 member organizations that issue them: a prefix says which of them issued the number, not where the product comes from.

What does matter are the ranges that change what you do with the code. The validator names these, all from GS1's list:[^gs1-prefix]

| Prefix                    | What it is                                                                                         | What to do                                                              |
| ------------------------- | -------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- |
| 020 to 029 and 200 to 299 | Restricted circulation numbers within a geographic region, defined by each GS1 member organization | Don't publish them as `gtin`: outside that region they identify nothing |
| 040 to 049                | Restricted circulation numbers within a company                                                    | Same: they're internal numbers                                          |
| 977                       | Serial publications (ISSN)                                                                         | It's a magazine or a newspaper                                          |
| 978 and 979               | Books (ISBN)                                                                                       | Publish it as `isbn`                                                    |
| 980                       | Refund receipts                                                                                    | It isn't a product                                                      |
| 981 to 983 and 99         | GS1 coupons                                                                                        | It isn't a product                                                      |

Any other prefix comes out as "A GS1 company prefix.", and nothing more: the validator doesn't know whose number it is.

How the validator reads the prefix: in a GTIN-13, the first three digits; in a GTIN-12, with a zero in front, because GS1 says a 12-digit GTIN carries an implied leading zero and that the prefix of `614141234561` is 061, not 614;[^gs1-prefix] and in a GTIN-14, skipping its first digit. In a GTIN-8 it doesn't read the prefix at all: those numbers have their own ranges.

## Which Schema.org property to use

In [Product](/glossary/product-schema/) markup, Schema.org has one general property, `gtin`, and one per length, which `gtin` generalizes.[^schemaorg-gtin] Google accepts the general one, but **recommends the most specific one that applies**, and only accepts the GTIN in numeric form, not as a URL.[^google-merchant-listing] Schema.org does accept a GS1 Digital Link URL in `gtin`,[^schemaorg-gtin] so the [Schema.org validator](/glossary/schema-markup-validator/) can pass a value Google doesn't use.

| Length                | Property | Also known as                                                                    |
| --------------------- | -------- | -------------------------------------------------------------------------------- |
| 8                     | `gtin8`  | EAN-8[^schemaorg-gtin8]                                                          |
| 12                    | `gtin12` | UPC[^schemaorg-gtin12]                                                           |
| 13                    | `gtin13` | EAN-13; a 12-digit UPC becomes a GTIN-13 with a zero in front[^schemaorg-gtin13] |
| 14                    | `gtin14` | GTIN-14                                                                          |
| 13, prefix 978 or 979 | `isbn`   | ISBN-13                                                                          |

`isbn` comes with a condition: Google only accepts it on a `Book` node, so the node carries both types at once, `"@type": ["Product", "Book"]`, and Google advises the 13-digit form of the ISBN.[^google-merchant-listing]

Publish each code at the length it has. Schema.org says left-padding with zeros is not required or encouraged.[^schemaorg-gtin] The GTIN doesn't replace the [SKU](/glossary/sku/), which is your internal reference, or the [MPN](/glossary/mpn/), the manufacturer's reference: they are different [product attributes](/glossary/product-attributes/), and Google recommends all three for [merchant listings](/glossary/merchant-listings/).[^google-merchant-listing]

## What a valid check digit doesn't prove

The check digit is calculated with an algorithm from the other digits,[^gs1-calculator] and anyone can do it: you just did, with the example. That's why **a code that's valid here is a well-formed code, not an assigned one**. It doesn't prove the number was issued to a company, or that it belongs to the product in front of you.

GS1 answers that. To use its keys, a company first needs a GS1 Company Prefix, which it gets from the GS1 organization in its country,[^gs1-prefix] and its Verified by GS1 service lets you search for and verify the information behind a barcode number.[^gs1-verified] If you have doubts about a code, especially one a supplier gave you or one that came out of a spreadsheet, look it up there.

## What we tested

Tested on: browser and version, date.

| Code            | Type                                           | Validator | GS1 calculator | Verified by GS1 | Match? |
| --------------- | ---------------------------------------------- | --------- | -------------- | --------------- | ------ |
| `9521234567899` | This page's example                            |           |                |                 |        |
|                 | GTIN-8                                         |           |                |                 |        |
|                 | 12-digit UPC and the same with a zero in front |           |                |                 |        |
|                 | GTIN-14                                        |           |                |                 |        |
|                 | ISBN-13                                        |           |                |                 |        |
|                 | Restricted circulation                         |           |                |                 |        |
|                 | One digit changed                              |           |                |                 |        |
|                 | Two digits swapped                             |           |                |                 |        |
