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.
Size code
The first character gives the length (2 = 20 ft, 4 = 40 ft, L = 45 ft) and the second gives height (for example 2 = 8 ft 6 in, 5 = 9 ft 6 in high cube).
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.
Where This Fits
- Type code: The last two characters give the type: G for general purpose, R for reefer, U for open top, P for platform and flat rack, T for tank, followed by a detail digit.
- Common examples: 22G1 is a 20 ft standard dry container, 42G1 a 40 ft standard, 45G1 a 40 ft high cube, and 45R1 a 40 ft high-cube reefer.
Extract It with the API
Read the document from a photo and validate the returned fields.
Prerequisite: Python 3.9+, `pip install requests`, and a STRUCTOCR_API_KEY
import base64
import os
import requests
with open("container.jpg", "rb") as image_file:
image = base64.b64encode(image_file.read()).decode("ascii")
response = requests.post(
"https://api.structocr.com/v1/container",
headers={"x-api-key": os.environ["STRUCTOCR_API_KEY"]},
json={"img": image},
timeout=30,
)
response.raise_for_status()
data = response.json()["data"]
print("container_number:", data.get("container_number"))
print("is_valid:", data.get("is_valid"))
print("confidence:", data.get("confidence"))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
- •Type code: The last two characters give the type: G for general purpose, R for reefer, U for open top, P for platform and flat rack, T for tank, followed by a detail digit.
- •Common examples: 22G1 is a 20 ft standard dry container, 42G1 a 40 ft standard, 45G1 a 40 ft high cube, and 45R1 a 40 ft high-cube reefer.
- •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.
{
"Size code": "The first character gives the length (2 = 20 ft, 4 = 40 ft, L = 45 ft) and the second gives height (for example 2 = 8 ft 6 in, 5 = 9 ft 6 in high cube)..",
"Type code": "The last two characters give the type: G for general purpose, R for reefer, U for open top, P for platform and flat rack, T for tank, followed by a detail digit..",
"Common examples": "22G1 is a 20 ft standard dry container, 42G1 a 40 ft standard, 45G1 a 40 ft high cube, and 45R1 a 40 ft high-cube reefer.."
}Frequently Asked Questions
Does the API read size-type codes?
The container API focuses on the container number. Capture the size-type code separately if your workflow needs it.
Why does the code matter?
Terminals and depots use it for stacking, billing, and equipment planning.
You May Also Like
Related tutorials, platform guides, and comparisons
Node.js Shipping Container OCR API
Tutorial: How to use the StructOCR Node.js SDK to extract data from Shipping Containers. Upload an image for a free test! Includes code samples and JSON schema.
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.
ISO 6346 Container Number Structure Explained
How a shipping container number is built: owner code, equipment category, serial number, and check digit, with examples.
Go Shipping Container OCR API
Upload an image for a free test! Tutorial: Learn how to use the StructOCR Go Client to extract data from Shipping Containers. Extract ISO 6346 container numbers and check them against the ISO check digit. Includes code samples and JSON schema.
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.
Jaguar VIN Location and VIN OCR API
Where to find the VIN on a Jaguar, what its first characters mean, and how to read it from a photo with an API and decode the model year.
Norway 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 Norway passports.
Pakistan CNIC OCR Python SDK
Python Tutorial: Automate KYC in Pakistan. Extract data from CNIC using StructOCR Python SDK. Supports native text.
Norway Passport OCR with Python SDK
Use the official StructOCR Python SDK and FastAPI to extract structured MRZ and VIZ data from Norway passports with a server-side integration.
Pakistan 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 Pakistan passports.
Technical Comparisons & Integrations
Explore platform integrations and competitive analysis
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.
Manual TOS Entry vs. Container OCR Automation API
Analyzing the ROI and operational efficiency of replacing manual gate checkers with an automated Container OCR API in logistics yards.
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.