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.
Python Implementation
A minimal, dependency-free implementation you can use to validate OCR output.
Prerequisite: Python 3.9+
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")) # -> 3Technical 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
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 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 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.
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.
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.
ISO 6346 Container Number Structure Explained
How a shipping container number is built: owner code, equipment category, serial number, and check digit, with examples.
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.
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.
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.
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.
Technical Comparisons & Integrations
Explore platform integrations and competitive analysis
Tesseract OCR vs. StructOCR API for ISO 6346 Container Numbers
A technical comparison for developers evaluating open-source Tesseract vs. a dedicated cloud API for extracting shipping container numbers.
Add Container OCR to Your v0 App in 5 Minutes
Step-by-step guide to integrating the StructOCR shipping container API into a v0 by Vercel app. Build logistics and yard management tools with zero backend.
Add Container OCR to Your Bolt.new App in 5 Minutes
Step-by-step guide to integrating the StructOCR shipping container API into a Bolt.new app. Build logistics and yard management tools right in your browser.
Add Container OCR using Cursor in 5 Minutes
Step-by-step guide to integrating the StructOCR shipping container API using the Cursor AI code editor. Build logistics and yard management tools rapidly.
Google Cloud Vision vs. StructOCR API for Shipping Containers
Comparing generic enterprise OCR solutions like Google Cloud Vision against StructOCR's purpose-built API for ISO 6346 shipping container recognition.
Add Container OCR to Your Lovable.dev App in 5 Minutes
Step-by-step guide to integrating the StructOCR shipping container API into a Lovable.dev app. Build logistics and yard management tools with zero backend.
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.