ISO 6346 Container Check Digit Calculation

Calculate and validate a shipping container check digit: letter values that skip multiples of 11, powers of two, and Python code.

Letter values

Letters map to numbers starting at A=10 and skipping multiples of 11: A=10, B=12, C=13 … K=21, L=23 … U=32, V=34 … Z=38. Digits keep their value.

Extracting It Automatically

When you read this data from photos, the Container Number OCR API returns it as structured JSON, and you can apply the rules on this page as validation. Try it with the free scanner. To check a list of numbers without writing code, use the free container check digit calculator.

Where This Fits

  • Weights: Multiply the value at position i (0–9) by 2 to the power of i, then add the products.
  • Remainder: Take the sum modulo 11, then modulo 10. The result is the check digit, so a remainder of 10 becomes 0.
Need more testing? Create a free account to get 200 free credits (equals 100 Passport scans).

Python Implementation

A minimal, dependency-free implementation you can use to validate OCR output.

Prerequisite: Python 3.9+

PYTHON EXAMPLE
def letter_values():
    values, n = {}, 10
    for char in "ABCDEFGHIJKLMNOPQRSTUVWXYZ":
        if n % 11 == 0:
            n += 1
        values[char] = n
        n += 1
    return values

VALUES = {**letter_values(), **{str(d): d for d in range(10)}}

def iso6346_check_digit(prefix10: str) -> int:
    total = sum(VALUES[c] * (2 ** i) for i, c in enumerate(prefix10.upper()))
    return total % 11 % 10

print(iso6346_check_digit("CSQU305438"))  # -> 3

Technical Specs

  • •Endpoint: POST https://api.structocr.com/v1/container
  • •Authentication: x-api-key request header
  • •Inputs: JPG, PNG, or WebP as Base64 JSON; maximum 4.5MB
  • •Price: 1 credit per successful request; failed requests are not billed
  • •Free trial: 200 free credits on sign-up, no credit card required

Key Features

  • •Weights: Multiply the value at position i (0–9) by 2 to the power of i, then add the products.
  • •Remainder: Take the sum modulo 11, then modulo 10. The result is the check digit, so a remainder of 10 becomes 0.
  • •Validate after OCR: Apply these rules to API output before storing it.

Reference Summary

Key facts from this page in structured form, for quick lookup.

{
  "Letter values": "Letters map to numbers starting at A=10 and skipping multiples of 11: A=10, B=12, C=13 … K=21, L=23 … U=32, V=34 … Z=38.",
  "Weights": "Multiply the value at position i (0–9) by 2 to the power of i, then add the products..",
  "Remainder": "Take the sum modulo 11, then modulo 10."
}

Frequently Asked Questions

Why validate the check digit?

It catches most single-character misreads, which is essential at automated gates.

Does the API validate it?

Yes. The is_valid flag reports whether the check digit matches.

You May Also Like

Related tutorials, platform guides, and comparisons

Tutorial

Anyline Container Scanner Alternative: Container Number OCR API

Anyline Container Scanner compared with the StructOCR REST API for container number extraction: deployment, pricing model, and when each fits.

Container
Tutorial

Container Number OCR API Pricing and Cost per Scan

What container number OCR costs with StructOCR: 1 credit per successful scan, prepaid credits that never expire, and no charge for failed requests.

Container
Tutorial

Container Size and Type Codes (22G1, 45G1, 45R1)

Read ISO 6346 size and type codes such as 22G1, 42G1, 45G1, and 45R1 to tell container length, height, and type apart.

Container
Tutorial

Java Shipping Container OCR API

Upload an image for a free test! Tutorial: Learn how to use the StructOCR Java Client to extract data from Shipping Containers. Extract ISO 6346 container numbers and check them against the ISO check digit.

Java · Container
Tutorial

PHP Shipping Container OCR API

Tutorial: Learn how to use the StructOCR PHP Client via cURL for shipping container OCR. Upload an image for a free test! Extract ISO 6346 container numbers and check them against the ISO check digit. Includes code samples and JSON schemas.

PHP · Container
Tutorial

ISO 6346 Container Number Structure Explained

How a shipping container number is built: owner code, equipment category, serial number, and check digit, with examples.

Container
Country Tutorial

New Zealand Passport OCR with Node.js SDK

Use the official StructOCR Node.js SDK with TypeScript and Express to extract structured MRZ and VIZ data from New Zealand passports.

Node.js · Passport
Country Tutorial

Netherlands Passport OCR with Python SDK

Use the official StructOCR Python SDK and FastAPI to extract structured MRZ and VIZ data from Netherlands passports with a server-side integration.

Python · Passport
Country Tutorial

Netherlands Identiteitskaart OCR Python SDK

Python Tutorial: Automate KYC in Netherlands. Extract data from Identiteitskaart using StructOCR Python SDK. Supports native text and MRZ extraction.

Python · identiteitskaart
Country Tutorial

Netherlands Passport OCR with Node.js SDK

Use the official StructOCR Node.js SDK with TypeScript and Express to extract structured MRZ and VIZ data from Netherlands passports.

Node.js · Passport

Technical Comparisons & Integrations

Explore platform integrations and competitive analysis

From tutorial to production in 5 minutes.

You've seen the code. Now get your API key, grab your 200 free credits, and see it work with your own images. No credit card required.

Instant Access Cancel Anytime No Credit Card