* * * GUIDES * * *
How to OCR a receipt in Python.
Receipts are the worst OCR input there is: thermal fade, crumples, photos taken at an angle. Classic engines (pytesseract) need a preprocessing pipeline; a vision-language model just reads them. Here's the whole thing in Python.
01 / INSTALL AND GET A KEY
One dependency. Keys are free — 100 pages/month, no card — at pennyocr.com/dashboard.
pip install pennyocr
export PENNYOCR_API_KEY=pk_live_...02 / READ THE RECEIPT
Three lines. Works on JPEG photos, PNG screenshots and PDF scans alike.
from pennyocr import PennyOCR
result = PennyOCR().ocr("receipt.jpg", format="text")
print(result.text)03 / WHAT YOU GET BACK
Verbatim text in reading order. From a coffee-shop receipt photo:
BLUE BOTTLE COFFEE
315 LINDEN ST, OAKLAND CA
1x CAPPUCCINO 5.50
2x LATTE 11.00
SUBTOTAL 26.50
TAX (8.75%) 2.32
TOTAL 28.8204 / PARSE THE AMOUNTS
Totals are the point of receipt OCR. A regex over clean text is usually all you need:
import re
amounts = re.findall(r"(\d+\.\d{2})", result.text)
total = max(map(float, amounts)) # the total is almost always the largest
print(f"total: ${total}")05 / BATCH A FOLDER
from pathlib import Path
client = PennyOCR()
for f in Path("receipts/").glob("*.jpg"):
text = client.ocr(f, format="text").text
print(f.name, "->", text.splitlines()[0]) # $0.00075 per receiptCost check: 1,000 receipts = $0.75, and your first 100 each month are free. If you need markdown with table structure instead, drop format="text".