AI Commercial Invoice Parser and OCR
Extract customs and trade data from commercial invoices without retyping each line. Review seller and buyer details, HS codes, quantities, unit prices, charges, currency, Incoterms and invoice totals before export or matching.
Commercial invoices drive customs entries, letters of credit and payment — and a single mistyped amount or HS code can hold a shipment at the border. GainingDocx extracts every line item, amount and party from your invoice as structured data you can trust.
Once parsed, the invoice can be cross-checked against the Bill of Lading and packing list from the same shipment: mismatched buyers, differing incoterms or totals that don't add up surface as red and amber discrepancies.
No sign-up for your first document · 15–30 seconds per page
Short answer
What a commercial invoice parser extracts
Every header field and every line item: seller and buyer, invoice number and date, currency, Incoterm and named place, payment terms, and per line the description, SKU, HS code, country of origin, quantity, unit price, amount and weights. Line amounts are recomputed against quantity × unit price, and the lines are totalled against the printed invoice total.
- Line items as rows, not as flattened text
- HS code and origin captured per line
- Arithmetic recomputed, not trusted
- Ready for three-way and shipment matching
Commercial Invoice Fields and Line Items Extracted
- Invoice number, date and PO number
- Seller and buyer with addresses and tax IDs
- Line items with description, HS code, quantity, unit price and amount
- Currency, subtotal, freight, insurance and total amount
- Incoterm, payment terms, L/C number and country of origin
- Bank details
Invoice Validation and Matching Checks
Computed in code — the AI never does the math.
- Gross ≥ net weight on every line that carries both
- Invoice date sanity (flagged when in the future)
- Cross-document: invoice totals vs packing list, incoterm vs B/L
- Duplicate invoice number detection across your documents
How to Extract Commercial Invoice Data
- 01
Upload or photograph the document — pages are compressed on your device.
- 02
Review the extracted fields; deterministic checks flag anything suspicious.
- 03
Export to Excel, CSV or JSON, or generate the counterpart document.
Why invoice line items are the hard part
Header extraction is comparatively easy — an invoice number is an invoice number wherever it sits on the page. Line items are where invoice parsing succeeds or fails, because a commercial invoice table is rarely a clean grid. Descriptions wrap over several lines, a single product occupies three visual rows, subtotals interleave with items, and continuation pages repeat headers in the middle of the data.
Getting this right matters because everything downstream is line-level. Customs classifies per line. Three-way matching compares per line. Duty is calculated per line. An extraction that returns a correct total and mangled lines has solved the easy half of the problem.
- Multi-line descriptions that belong to one item, not several
- Quantity and unit of measure printed together in one cell
- Unit prices with varying decimal precision across the same invoice
- Discount, charge and subtotal rows mixed into the item table
- Multi-page tables with repeated headers and carried-forward subtotals
- Currency symbols that are ambiguous between currencies
- HS codes printed with or without dots, and truncated to different lengths
The field inventory
| Group | Fields |
|---|---|
| Invoice | Invoice number, invoice date, due date, purchase order and contract references, exporter reference |
| Parties | Seller and exporter, buyer, consignee or ship-to, notify party, and any agent named |
| Trade terms | Currency as an ISO code, Incoterm and named place, rules edition, payment terms, country of origin, country of destination |
| Shipment | Mode of transport, carrier, vessel or flight, port of loading, port of discharge, transport document reference |
| Line items | Description, SKU or part number, HS code, country of origin, quantity, unit of measure, unit price, line amount, net weight, gross weight |
| Charges | Freight, insurance, packing, handling, discounts and any other charge shown as a separate line |
| Totals | Subtotal, charges, tax, invoice total, total packages, total net and gross weight |
| Certification | Declarations, destination control statements, signatory name, title and date |
Arithmetic and structural checks
The AI reads what is printed; deterministic code decides whether it is coherent. Invoice arithmetic is the clearest case for this — a total is either the sum of its parts or it is not, and no amount of model confidence changes that.
- Each line amount recomputed as quantity × unit price and compared with the printed amount
- Line amounts summed and compared with the printed subtotal
- Subtotal plus charges compared with the printed invoice total
- Currency checked for consistency across lines, charges and totals
- HS codes checked for structural plausibility — length, digit content and a valid chapter
- Net weight checked against gross weight per line and in total
- Incoterm validated against the published rule set and flagged where a maritime-only rule is used on containerised cargo
- Dates checked for plausible ordering against each other and against the transport document
A total that does not add up is a real finding
It usually means a line was added, edited or removed after the total was written — which is exactly the situation you want to catch before the invoice is filed with customs or presented under a credit. It is one of the most frequently triggered checks on real documents, and it is almost never a false positive.
Matching the invoice to the rest of the shipment
An invoice is rarely wrong in isolation. It is wrong relative to something — the purchase order that authorised the purchase, the packing list that describes what was actually shipped, the Bill of Lading that records what the carrier received, or the goods receipt confirming what arrived.
| Compare with | What to check |
|---|---|
| Purchase order | Item, quantity, unit price, currency, delivery terms — the classic price and quantity variance check |
| Packing list | Line quantities, SKUs, net and gross weights, package counts, origin |
| Bill of Lading or air waybill | Parties, references, description, weights, and whether shipment dates are consistent |
| Goods receipt | Accepted quantity against invoiced quantity, and rejected or damaged quantities |
| Certificate of origin | Description, quantity, invoice reference and the origin claimed |
| Letter of credit | Description wording, amount, tolerance, currency, and required declarations |
Using the extracted data
- 1Review the flagged fields first — arithmetic failures, HS code structure and weight relationships are ordered by severity rather than by page position.
- 2Correct anything the source document genuinely shows differently, so the record reflects the document rather than the model.
- 3Group the invoice with the packing list, transport document and purchase order for the same shipment.
- 4Work the resulting discrepancy list, which is prioritised by what actually delays clearance or payment.
- 5Export to Excel with the line items intact, to CSV for a flat feed, or to JSON where the array structure needs to survive.
- 6Reuse the reviewed data to generate a packing list or shipping-instruction draft rather than retyping it.
Try it on your own document — free, no sign-up
Start parsingCommercial Invoice Parser FAQ
What teams ask most often before putting commercial invoice parser output into a customs filing, a payment run or a downstream system.
What data is extracted from a commercial invoice?
Header fields — invoice number and date, seller, buyer and consignee, currency, Incoterm and named place, payment terms, origin and destination, transport details — plus every line item with its description, SKU, HS code, origin, quantity, unit of measure, unit price, amount and weights, and all charge and total lines.
Does it preserve line items or just totals?
Line items are returned as structured rows, because everything downstream is line-level: customs classifies per line, three-way matching compares per line, and duty is calculated per line. Multi-line descriptions are reassembled into their item, and subtotal or charge rows interleaved in the table are separated from the items themselves.
Are HS codes extracted?
Yes, per line where they are printed, and they are checked for structural plausibility — length, digit content and whether the chapter exists. Codes printed with dots, without dots, or truncated to six, eight or ten digits are normalised for comparison while the printed form is preserved. Classification itself remains the importer's responsibility.
Is the invoice arithmetic checked?
Yes, in deterministic code. Each line amount is recomputed as quantity × unit price, the lines are summed against the printed subtotal, and the subtotal plus charges is compared with the invoice total. A total that does not equal its parts is one of the most frequently triggered checks on real documents and is almost never a false positive.
Can it match the invoice against a purchase order?
Yes. Grouping the invoice with the purchase order and, where available, the goods receipt performs a three-way comparison at header and line level, reporting price variances, quantity variances, unmatched lines and currency or terms differences rather than requiring a manual reconciliation.
What about multi-currency invoices?
Currency is captured per invoice and checked for consistency across lines, charges and totals. An invoice mixing currencies without a stated conversion is flagged, because it is either an error or something customs will query. Where a conversion rate is printed, it is captured as a field rather than applied silently.
Does it handle multi-page invoices?
Yes. Tables that run across page breaks are reassembled, repeated column headers on continuation pages are recognised as headers rather than data rows, and carried-forward subtotals are distinguished from item lines. Long invoices take proportionally longer because every page is processed.
Can it read invoices in other languages?
Yes, for the languages the extraction layer supports, and field labels are mapped to the same structured model regardless of the language they are printed in. Values, party names and descriptions are preserved as written rather than translated, so the record matches the document a customs officer will be holding.
Does the parser validate the Incoterm?
It checks the rule against the published set and flags a maritime-only rule — FAS, FOB, CFR or CIF — used on containerised cargo, which is one of the most common Incoterm errors in practice. It also flags a rule stated without a named place or without the rules edition, both of which leave the term commercially incomplete.
Can it detect an under-declared or fraudulent invoice?
No. Validation detects internal inconsistency — arithmetic that does not add up, weights that contradict each other, references that do not match other documents. It cannot assess whether a stated price reflects the real transaction. Valuation questions are for the importer, its broker and, ultimately, customs.
What formats can I export invoice data to?
Excel with separate summary and line-item sheets, CSV for a flat feed, structured JSON that preserves the line array, and a PDF review report showing the extracted values alongside any findings. The JSON structure is the right choice where a downstream system needs the line detail intact.
Can the invoice data be reused to create other documents?
Yes. Reviewed invoice data can populate a packing list or shipping-instruction draft, so descriptions, SKUs, HS codes, quantities and party details carry across rather than being retyped — which is also what keeps the documents consistent with each other from the outset.
Does the parser calculate totals itself?
No — and that's deliberate. Values are copied exactly as printed. Deterministic rules then verify whether the printed lines add up to the printed total and flag the difference if they don't.
Can I generate a packing list from the invoice?
Yes. One click creates a packing list draft with every line mapped from the invoice — you edit, then download the PDF.
How long does parsing take?
Typically 15–30 seconds per page, streamed live so you see fields appear as they are read.
Related tools, templates and guides
- Commercial invoice vs packing listWhich document customs uses for value, and which fields must agree.
- HS code finderVerify the classification on each invoice line.
- Commercial invoice templateBuild a customs-ready invoice with the fields in the right places.
- Three-way document matchingCompare the invoice against the PO and goods receipt automatically.