A simple, self-hosted web application for optical character recognition (OCR) powered by Mistral AI's OCR API.
- Document Processing: Upload PDF files or images (JPG, PNG, GIF, BMP, TIFF, WebP) up to 20MB
- Secure API Key Storage: Your Mistral API key is encrypted locally in your browser using AES-256-GCM with PBKDF2 key derivation
- Multiple Export Formats: Download results as Markdown, JSON, and extract embedded images
- Privacy-Focused: All processing happens through your own proxy server - no data stored on external servers
- Choice of models: proxy server and frontend are prepared for choice between two models (currently Mistral OCR 2 and 3), As long as Mistral keeps the same API structure (/v1/ocr endpoint with the same request format), you can update the model identifiers in proxy-server.js:
Line 90:
const validModels = ['mistral-ocr-2505', 'mistral-ocr-2512']; - Simple Setup: Just two files - an HTML frontend and a Node.js proxy server
- Node.js (v14 or higher)
- A Mistral AI API key
-
Clone the repository:
git clone https://github.com/PetrAPConsulting/Mistral-OCR.git cd mistral-ocr -
Install dependencies:
npm install
-
Start the proxy server:
npm start
-
Open web browser and open
http://localhost:3001
-
Enter your Mistral API key and a password to encrypt it (the key is stored encrypted locally in your browser)
-
Select model for OCR, MistralOCR 2 is default model with API endpoint 'mistral-ocr-2505'
-
Upload a document and click "Process with OCR"
-
Download results in your preferred format
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ │ │ │ │ │
│ Browser (HTML) │ ───► │ Proxy Server │ ───► │ Mistral API │
│ │ │ (localhost) │ │ │
└─────────────────┘ └─────────────────┘ └─────────────────┘
The proxy server is necessary because browsers block direct API calls to Mistral due to CORS restrictions. The proxy:
- Receives file uploads from the browser
- Forwards requests to Mistral's API
- Returns OCR results to the browser
| Endpoint | Method | Description |
|---|---|---|
/health |
GET | Health check - returns server status |
/api/upload |
POST | Upload a file to Mistral for processing |
/api/ocr |
POST | Process uploaded file with OCR |
- API Key Encryption: Your API key is encrypted using AES-256-GCM before being stored in localStorage. A password-derived key (PBKDF2, 100,000 iterations) is used for encryption.
- Local Processing: The proxy server runs locally - your documents are not stored anywhere.
- Session-Based: API keys are only decrypted into memory for the current session.
mistral-ocr/
├── index.html # Frontend
├── Assets # Frontend components
└── favicon.png
└── images.png
├── proxy-server.js # Node.js proxy server
├── package.json # Dependencies configuration
├── node_modules # Installed dependencies
└── README.md # This file
- Express - Web server framework
- Multer - File upload handling
- CORS - Cross-origin resource sharing
- node-fetch - HTTP client for API calls
- form-data - Multipart form data handling
MIT License - see LICENSE for details.
ver. 1.2.0 December 2025
- Powered by Mistral AI OCR API
- Developed by AP Consulting