How to Validate SSCC Codes — Format, Algorithm & Tools

What is an SSCC?

The Serial Shipping Container Code (SSCC) is an 18-digit GS1 identifier used in logistics to uniquely identify a physical shipping unit — a pallet, box, roll cage, or any other logistic unit. It is the primary identifier used in supply chain transactions between trading partners.

SSCCs appear in two main contexts:

The SSCC is always accompanied by the Application Identifier (AI) 00, which signals to any GS1-compliant system that what follows is an SSCC.

SSCC Structure

An SSCC has exactly 18 digits, structured as follows:

AI Extension GS1 Company Prefix Serial Reference Check Digit
(00) 3 56012345 00000001 6
not stored 1 digit 7–10 digits variable 1 digit
Important: The GS1 Company Prefix identifies the organisation that issued the SSCC, not necessarily the country of origin of the goods. A Portuguese company with prefix 560 may ship goods manufactured anywhere in the world.

Check Digit Algorithm

The SSCC check digit uses the standard GS1 Modulo-10 algorithm. Given the 17-digit body:

  1. Starting from the rightmost digit, multiply alternating digits by 3 and 1
  2. Sum all products
  3. Check digit = (10 − (sum mod 10)) mod 10

Worked Example

Body: 35601234500000001

Position (from right) 123456789 1011121314151617
Digit 100000005 43210653
Multiplier 313131313 13131313
Product 3000000015 492301859
Sum = 68 → Check digit = (10 − (68 mod 10)) mod 10 = (10 − 8) mod 10 = 2

Full SSCC: (00) 35601234500000001 2

Quick check: If the result of (sum + check_digit) mod 10 === 0, the SSCC is valid. This is the fastest way to validate an existing 18-digit SSCC.

Common Mistakes

1. Confusing the AI with the SSCC digits

The AI (00) is a label, not part of the 18 digits. When a barcode is scanned with a GS1-128 reader, the raw output is often 00 followed by the 18 digits — giving 20 characters total. Always strip the leading 00 before validating the check digit.

2. Wrong digit count

An SSCC body is always exactly 17 digits (before the check digit) or 18 digits (including it). Numbers with 19, 20 or more digits are either GTINs, IBANs, or other identifiers — not SSCCs.

3. Padding zeros

Some ERP systems store SSCCs in fixed-width fields padded with leading zeros. A 20-character field starting with 00 followed by an 18-digit SSCC, or a 21-character field where the last character is a line number — always extract exactly 18 digits for the SSCC.

4. GS1 prefix vs country of origin

The GS1 prefix (first 3 digits of the SSCC after the extension digit) identifies the GS1 member organisation that issued the company prefix — not the country where the goods were made or shipped from. A company registered in Portugal (560) may ship from a warehouse in Spain.

JavaScript Implementation

Here is a complete, dependency-free JavaScript implementation for validating and generating SSCC check digits. It uses BigInt to safely handle the large numbers involved.

/**
 * Calculate the GS1 check digit for a 17-digit SSCC body.
 * @param {string} body17 - 17-digit string (no check digit)
 * @returns {number} check digit (0-9)
 */
function getCheckDigit(body17) {
    let sum = 0;
    const digits = body17.split('').reverse();
    for (let i = 0; i < digits.length; i++) {
        sum += parseInt(digits[i]) * (i % 2 === 0 ? 3 : 1);
    }
    return (10 - (sum % 10)) % 10;
}

/**
 * Validate an 18-digit SSCC string.
 * @param {string} sscc18 - 18-digit SSCC (without AI prefix)
 * @returns {{ valid: boolean, expected: number, provided: number }}
 */
function validateSSCC(sscc18) {
    const digits = sscc18.replace(/\D/g, '');
    if (digits.length !== 18) throw new Error('SSCC must be 18 digits');

    const body     = digits.substring(0, 17);
    const provided = parseInt(digits[17]);
    const expected = getCheckDigit(body);

    return { valid: provided === expected, expected, provided };
}

/**
 * Normalise any SSCC input to an 18-digit string.
 * Handles: 17 digits (generates CD), 18 digits, 20 digits with AI "00".
 */
function normaliseSSCC(raw) {
    const d = raw.replace(/\D/g, '');
    if (d.length === 17) return d + getCheckDigit(d);
    if (d.length === 18) return d;
    if (d.length === 20 && d.startsWith('00')) return d.substring(2);
    throw new Error(`Unexpected length: ${d.length}`);
}

// Examples
validateSSCC('356012345000000012');  // { valid: true, expected: 2, provided: 2 }
validateSSCC('356012345000000019');  // { valid: false, expected: 2, provided: 9 }
normaliseSSCC('00356012345000000012'); // '356012345000000012' (strips AI)
normaliseSSCC('35601234500000001');   // '356012345000000012' (generates CD)

Extracting SSCCs from EDIFACT Files

In EDIFACT messages, SSCCs appear in several segments. The most common is GIN with qualifier BJ (Goods Identity Number, SSCC), used in DESADV (Despatch Advice) and IFTMIN (Forwarding Instruction).

Segment Description Example
GIN+BJ:<SSCC> Primary SSCC segment in DESADV / IFTMIN GIN+BJ:356012345000000012'
RFF+SI:<SSCC> Reference, qualifier SI = Shipment ID RFF+SI:356012345000000012'
RFF+AAK:<SSCC> Reference, qualifier AAK = Despatch number RFF+AAK:356012345000000012'
PAC Package segment — SSCC sometimes embedded PAC+1++09:356012345000000012'

Parsing GIN+BJ with JavaScript

/**
 * Extract all SSCCs from an EDIFACT message string.
 * Handles custom UNA delimiters.
 */
function extractSSCCsFromEDIFACT(text) {
    const ssccList = [];

    // Read custom delimiters from UNA service string
    let compSep = ':', elemSep = '+', segTerm = "'";
    const una = text.match(/^UNA(.{6})/);
    if (una) {
        compSep = una[1][0];
        elemSep = una[1][1];
        segTerm = una[1][5];
    }

    const segments = text
        .replace(/\r?\n/g, '')
        .split(segTerm)
        .map(s => s.trim())
        .filter(Boolean);

    for (const seg of segments) {
        const parts = seg.split(elemSep);
        if (parts[0] !== 'GIN') continue;

        for (const el of parts.slice(1)) {
            const [qualifier, value] = el.split(compSep);
            if (qualifier === 'BJ' && value) {
                const result = validateSSCC(value);
                ssccList.push({ sscc: value, ...result });
            }
        }
    }
    return ssccList;
}
Note on custom delimiters: EDIFACT allows trading partners to define custom component, element and segment separators in the UNA service string. Always read the UNA header before parsing — defaulting to : + ' will silently fail on non-standard files.

Free Online Validator

If you need to validate SSCCs without writing code, SSCC Pro Vision is a free, open-source tool that runs entirely in the browser. No installation, no backend, no data leaves your device.

Try SSCC Pro Vision

Free, open-source SSCC validator and check digit calculator — runs entirely in your browser.

Open Validator →