If you have ever built software for logistics, e-commerce supply chains, or ERP integrations, you have probably run into strings like MSCU5289104 or COSU6418293010.

At first glance, validating a shipping container number and routing a user to the right ocean carrier looks like a simple regex problem. Once you handle real-world shipments across 90+ carriers, you quickly hit edge cases: check digits, leased equipment prefixes, and wildly inconsistent Bill of Lading (B/L) formats.

Here is how ISO 6346 container validation actually works in code, where simple prefix matching breaks down, and how we structured a free lookup tool to handle it cleanly.

1. Anatomy of an ISO 6346 Container Number

Every standard intermodal ocean container number has 11 characters:

  • Owner code (3 letters): Registered with the Bureau International des Containers (BIC).
  • Category identifier (1 letter): Usually U for freight containers (J for detachable freight equipment, Z for trailers/chassis).
  • Serial number (6 digits): Assigned by the equipment owner.
  • Check digit (1 digit): Computed from the first 10 characters to catch typos.

2. Implementing the ISO 6346 Check Digit in JavaScript

Letters A–Z map to numbers starting at 10, skipping multiples of 11 (11, 22, 33). Each of the first 10 characters is multiplied by 2^i, summed, and taken modulo 11 (with 10 wrapping to 0):

function iso6346CharValue(ch) { if (ch >= "0" && ch <= "9") return Number(ch); const code = ch.charCodeAt(0) - 65; // A = 0 let val = 10 + code; if (val >= 11) val += 1; if (val >= 22) val += 1; if (val >= 33) val += 1; return val; } export function isValidContainerNumber(raw) { const id = raw.trim().toUpperCase(); if (!/^[A-Z]{3}[UJZ]\d{7}$/.test(id)) return false; let sum = 0; for (let i = 0; i < 10; i++) { sum += iso6346CharValue(id[i]) * (1 << i); } const expected = (sum % 11) % 10; return expected === Number(id[10]); } 

This alone catches the vast majority of copy-paste typos before you ever touch a carrier lookup.

3. Where Prefix Tables Break: Leased Containers

A static prefix-to-carrier map works for carrier-owned boxes (MSCU -> MSC, MSKU -> Maersk, CMAU -> CMA CGM, ONEU -> ONE, HLXU -> Hapag-Lloyd).

The trap is leased containers. Prefixes like TCKU / TGHU (Textainer), TRHU / TTNU (Triton), CAIU (CAI), and FBIU (Florens) identify the leasing company, not the ocean carrier moving the cargo. A naive prefix table either fails or points to the wrong line; you need to resolve the current lessee carrier or fall back to the Bill of Lading or booking number.

4. Bill of Lading & Booking Numbers Have No Universal Standard

Unlike ISO 6346 container numbers, B/L and booking formats vary completely by carrier:

  • Some use a 4-letter SCAC prefix + digits.
  • Others use pure 9- or 10-digit numbers or mixed alphanumeric templates.
  • On the UX side, each carrier hosts its tracking form at a different URL—some accept the number directly in the query string, while others require selecting the tracking type and filling a form field manually.

5. Putting It Together

We packaged this rule set into Lines Tracking, a free web tool and browser extension covering 90+ ocean carriers:

  • Paste a container, B/L, or booking number on the tracking lookup page to identify the tracking type and carrier (including leased prefixes for Textainer, Triton, and CAI), then open that carrier's official tracking page directly. Cargo status stays on the carrier's official website.
  • For folks copying numbers out of emails or PDFs all day, the free Chrome extension lets you highlight any number on a webpage or PDF to open and auto-fill supported carrier forms.
  • We also expose public sailing schedules, vessel schedules, ports, routes, and voyages with no sign-in required.

If you have built logistics integrations or dealt with quirky carrier B/L patterns, I would love to hear what edge cases tripped you up!