InvoiceSnap AI: Local AI Turns Receipt Photos into Structured Expense Sheets

Open-source InvoiceSnap uses Tesseract plus a local Gemma model to turn receipt images into structured tables exportable as CSV.
InvoiceSnap AI is an open-source lightweight tool that helps freelancers and small business owners turn receipt images into structured tables and export CSV. Its workflow has two steps: Tesseract OCR reads Pillow-preprocessed receipt text, then the text goes to a Gemma model running locally via Ollama, which outputs JSON with merchant, date, amount, and category, with backend normalization and validation. The app uses a Flask backend and vanilla JavaScript frontend, storing records in browser localStorage with no remote database. Local operation protects privacy and avoids API fees, but the author stresses human review is essential, with regex rules as a fallback when AI fails. The current version lacks authentication and cloud sync, and the author plans to prioritize extraction reliability.
From Receipts to Spreadsheets: A Lightweight Local AI Tool
Freelancers, indie developers, and small business owners are often plagued by receipt management—manually entering receipt information into spreadsheets is both time-consuming and error-prone. InvoiceSnap AI attempts to solve this pain point with open-source AI: upload a receipt image, and OCR plus a local large model extract the key information, which users can verify and then export as CSV.
The project author has open-sourced the complete code on GitHub (Leafyte/InvoiceSnap). The core philosophy is "small steps, fast iteration": rather than building an all-encompassing accounting platform, it focuses solely on the single workflow from receipt scanning to structured export.

Feature Breakdown: Recognition, Editing, Export
The app extracts four fields from receipts: merchant name, date, total amount, and expense category (dining, groceries, transportation, shopping, utilities, office, etc.). The extracted results appear in an editable table that supports item-by-item correction, record deletion, total amount viewing, and CSV export.
The tech stack stays lean: the Flask backend handles OCR processing, AI calls, data normalization, and API routing; the frontend uses vanilla JavaScript for uploading, table interaction, browser storage, and CSV export. Receipt images are not saved as application files after backend processing, and expense records are stored in browser localStorage, eliminating the need for a remote database and account system.
The author emphasizes that this design makes the codebase easy to understand, modify, and run locally.
Technical Core: How OCR and the Gemma Model Divide the Work
The workflow has two steps. First, Tesseract OCR reads the receipt text: the image is preprocessed with Pillow (grayscale, contrast enhancement, orientation correction, upscaling if necessary), then OCR outputs the raw text. Raw text often contains line breaks, recognition errors, and inconsistent formatting, making it unusable directly.
Second, the OCR text is sent to the Gemma open-source model running on a local Ollama service, with instructions to return structured JSON containing merchant, date, amount, and category. The backend then normalizes: validating that the category is in the predefined list, unifying supported date formats, and passing the result to the frontend.
This separation of responsibilities is key—Tesseract handles "reading," Gemma handles "understanding and organizing," Flask handles processing and validation, and JavaScript handles display and management. The author admits the model can still make mistakes, especially with blurry images, incomplete OCR, or multiple amounts appearing on a receipt, so a human review step is indispensable.
As a fallback, when the local AI request fails, the app attempts to extract information using regular expressions and keyword rules, and flags the results for users to double-check.
Tesseract OCR is an open-source optical character recognition engine initiated by HP Labs and now maintained by Google. It converts text regions in images into editable text through trained language models, supporting over 100 languages. Tesseract performs well on clear, upright printed text but is prone to errors on blurry, skewed, or handwritten content, so it often needs to be paired with image preprocessing (such as grayscale, binarization, denoising) to improve accuracy. In this project, Tesseract handles the low-level conversion "from pixels to characters," and its output quality directly determines whether the downstream large model can correctly understand the receipt content.
Ollama is a tool for running open-source large language models locally, offering a simple command-line and API interface, and supporting model families such as Llama, Gemma, and Mistral. It handles model downloading, loading, inference scheduling, and memory management, letting developers call large models on their personal computers without diving deep into the underlying frameworks. This project runs the Gemma model locally through Ollama, with all AI inference requests sent to a local service, thereby avoiding sending receipt text to remote APIs and balancing privacy and cost.
The Value and Boundaries of Local AI
Privacy is the primary consideration. Receipts may contain sensitive information such as personal spending and business expenses. Running locally means images are processed by the user's own computer, and AI requests go to local Ollama rather than remote providers, reducing the need for data to leave the device. The author also explicitly cautions: this is not a security guarantee, and users still need to protect their computer, browser data, and local services themselves.
In terms of cost, running open-weight models locally avoids the per-call fees and usage limits of hosted APIs, but hardware, electricity, installation, and maintenance costs remain. For a small tool with a manageable volume of receipts, this trade-off is worth trying.
Flexibility matters too: models can be swapped, prompts adjusted, and different local models evaluated against the same set of receipt samples, so developers aren't locked into a single hosted provider.
Open-weight models refer to large language models whose parameters (weights) are released under a public license and can be downloaded and run locally by anyone, such as the Gemma and Llama series. Unlike closed-source models that can only be accessed via API, open-weight models allow developers to complete inference on their own hardware, with no per-call fees and no exposure to a provider's usage limits or policy changes. The trade-off is that users bear the hardware (especially GPU memory), electricity, setup, and maintenance costs themselves, and model capabilities are usually weaker than top closed-source models. For tasks like receipt information extraction, open-weight models are already up to the job, making them a reasonable choice for a local-first approach.
Target Users and Commercial Possibilities
Target users include freelancers tracking business expenses, indie developers organizing project purchases, small business owners managing receipts, students organizing personal expenses, and consultants preparing expense sheets. The author explicitly states that the tool does not replace accounting software and does not provide tax advice.
Regarding commercialization, the author proposes two possibilities: a free local version plus paid installation assistance, customization, or integration services; or a customized version for freelancers and small businesses with specific category and export requirements. But he emphasizes these are only potential models—demand, extraction accuracy, and willingness to pay all need validation with real users.
Limitations and Improvement Directions
The main challenges of the current version include: varying receipt image quality affecting OCR accuracy; the language model possibly misjudging dates, totals, or categories, requiring human review of financial records; local operation has hardware requirements, and model startup and inference take time; additionally, authentication, cloud sync, bank integration, automatic tax calculation, and multi-user support are missing.
The author plans to prioritize improving reliability over stacking features: adding sample receipts for repeatable testing, improving date and currency detection, highlighting uncertain or missing fields, supporting PDF invoices, refining classification for different business types, and providing more detailed expense report exports.
PDF invoices differ from receipt images in their processing path: a PDF may be a scanned document (essentially an image, requiring rasterization to an image before OCR) or a native electronic invoice (text stored as text objects, which can be extracted directly without OCR). The latter bypasses OCR errors for higher extraction accuracy but requires parsing the PDF structure or using specialized libraries. Supporting PDFs means the app needs to determine the PDF type and select the appropriate processing pipeline, while also handling multi-page documents and more complex layouts—a direction not yet covered in the current version but planned for expansion.
Summary
InvoiceSnap AI is a pragmatic open-source experiment: combining Tesseract, a local Gemma model, Flask, and a lightweight frontend into a usable receipt management workflow. It demonstrates that open-weight models can be integrated into real software with a low barrier to entry, and it illustrates the privacy and cost trade-offs of a "local-first" approach. For developers looking to explore local AI applications, this codebase is a good starting point.
Related articles

WorkBuddy Full Tutorial: Build an AI Office Automation Agent from Scratch
A complete WorkBuddy tutorial: installation, three working modes, multimodal picture book video practice, expert team agent building, and workflow configuration for low-cost AI office automation.

WorkBuddy Agent Complete Guide: From Beginner to Automation in 7 Days
Based on Bilibili's 256-episode WorkBuddy masterclass, this systematically breaks down Tencent's AI office workbench core capabilities: Agent principles, Skill encapsulation, cross-platform connectors, scheduled automation, knowledge bases, and zero-code development, with learning path recommendations.

8 AI Accounts, 7 Failed: An Honest Review of Using AI to Get Work Done
Only 1 of 8 AI-run Bilibili accounts succeeded. We break down the real difference between "performing AI" and "using AI to get work done."