EAN Validator API: The Complete Guide

Need to validate EAN barcode numbers in your application? This guide covers everything you need to know about EAN validation via API, including EAN-8 and EAN-13 formats, checksum calculation, and implementation examples in multiple languages.

What is an EAN?

An EAN (European Article Number, now known as International Article Number) is a barcode standard used worldwide for marking retail products. EAN barcodes are also known as GTIN (Global Trade Item Number) when used in international trade.

A typical EAN-13 looks like this: 4006381333931

EAN Formats Explained

There are two main EAN formats:

EAN-13

The most common format with 13 digits. Includes country code, manufacturer code, product code, and check digit. Used on most retail products worldwide.

EAN-8

A shorter 8-digit format used for small packages where EAN-13 would be too large. Contains country code, product code, and check digit.

Note: UPC-A codes used in North America can be converted to EAN-13 by adding a leading zero.

Using the EAN Validator API

TinyFn provides a simple endpoint to validate EANs:

API Request
GET https://api.tinyfn.io/v1/validate/ean?ean=4006381333931
Headers: X-API-Key: your-api-key
Response
{
  "valid": true,
  "ean": "4006381333931",
  "format": "EAN-13",
  "country_code": "400",
  "country": "Germany",
  "check_digit": "1"
}

Parameters

Parameter Type Description
ean string EAN to validate (required)

Code Examples

JavaScript / Node.js

const response = await fetch(
  'https://api.tinyfn.io/v1/validate/ean?ean=4006381333931',
  { headers: { 'X-API-Key': 'your-api-key' } }
);
const result = await response.json();
console.log(result.valid); // true
console.log(result.format); // "EAN-13"

Python

import requests

response = requests.get(
    'https://api.tinyfn.io/v1/validate/ean',
    params={'ean': '4006381333931'},
    headers={'X-API-Key': 'your-api-key'}
)
result = response.json()
print(result['valid'])  # True
print(result['format'])  # "EAN-13"

cURL

curl "https://api.tinyfn.io/v1/validate/ean?ean=4006381333931" \
  -H "X-API-Key: your-api-key"

Common Use Cases

  • Inventory Management: Validate product barcodes during scanning
  • E-commerce: Verify product codes in listings
  • POS Systems: Validate scanned barcodes at checkout
  • Data Entry: Verify manually entered product codes
  • Supply Chain: Validate product identification in logistics

Best Practices

  1. Verify check digit: Always validate the EAN checksum
  2. Support both formats: Accept EAN-8 and EAN-13 inputs
  3. Handle UPC: Convert UPC-A to EAN-13 by adding leading zero
  4. Barcode quality: Ensure proper barcode printing for reliable scanning

Use via MCP

Your AI agent can call this tool directly via Model Context Protocol — no HTTP code needed. Add TinyFn to Claude Desktop, Cursor, or any MCP client:

{
  "mcpServers": {
    "tinyfn-validate": {
      "url": "https://api.tinyfn.io/mcp/validate/",
      "headers": {
        "X-API-Key": "your-api-key"
      }
    }
  }
}

See all validation tools available via MCP in our Validation MCP Tools for AI Agents guide.

Try the EAN Validator API

Get your free API key and start validating EAN codes in seconds.

Get Free API Key

Ready to try TinyFn?

Get your free API key and start building in minutes.

Get Free API Key