PHPackages                             pmigut/gtin-validator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. pmigut/gtin-validator

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

pmigut/gtin-validator
=====================

This library is a set of static methods for GTIN validation. Methods return true if given string is publicly available GTIN-8, GTIN-12, GTIN-13 or GTIN-14 code. Checks include format, check digit and prefix.

2.0.0(2mo ago)7175.2k↓57.3%12MITPHPPHP ^8.2CI failing

Since Jan 6Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/pmigut/gtin-validator)[ Packagist](https://packagist.org/packages/pmigut/gtin-validator)[ RSS](/packages/pmigut-gtin-validator/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (4)Dependencies (2)Versions (11)Used By (2)

This library is a set of static methods for GTIN validation.

The library is best suited for quick validation of many codes without instantiating a new object for each code. Simple `true` or `false` is returned and no additional details are provided on failure. Only trade product codes return `true`, codes with restricted or special use prefixes return `false`.

Supported codes

- GTIN-8 (former EAN-8)
- GTIN-12 (former UPC)
- GTIN-13 (former EAN-13)
- GTIN-14

Checks performed

- format
- check digit
- GS1 prefix

Implementation is based on GS1 General Specifications ver. 18, Jan 2018. Prefix list verified on 2 Jan 2026.

### Requirements

[](#requirements)

- PHP 8.2 or later
- ext-ctype

Users on PHP &lt; 8.2 should pin to `^1.0`.

### Installation

[](#installation)

```
$ composer require pmigut/gtin-validator
```

### Examples

[](#examples)

**Basic usage**

```
