npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

natscan

v1.1.2

Published

Offline OCR pipeline for React Native/Expo receipt scanning with multilingual support using ML Kit

Readme

natscan

Offline OCR pipeline for React Native/Expo receipt scanning with multilingual support (Simplified Chinese, Traditional Chinese, and English) using Google ML Kit.

Features

  • Offline Processing - No internet connection required
  • React Native 0.81 & Expo SDK 54+ Compatible - Works seamlessly with latest versions
  • Multilingual Support - English, Simplified Chinese, Traditional Chinese
  • Automatic Language Detection - Detects receipt language automatically
  • Native Performance - Uses Google ML Kit for fast, on-device OCR
  • Structured Data Extraction - Extracts 7 key fields from receipts plus raw OCR text
  • TypeScript Support - Full type definitions included
  • Cross-Platform - Works on both iOS and Android

Installation

npm install natscan

That's it! ML Kit will be installed automatically as a dependency.

iOS Setup

cd ios && pod install && cd ..

Quick Start

import { processReceipt } from "natscan";

// Process a receipt image
const result = await processReceipt("path/to/receipt.jpg");

console.log(result);
// {
//   receiptno: "INV-123456",
//   shopname: "ABC Supermarket",
//   date: "2025-12-19",
//   time: "14:30",
//   netAmount: 45.5,
//   grossAmount: 50.0,
//   totalItems: 5,
//   rawInput: "Full OCR text..."
// }

Response Format

The pipeline returns a ReceiptScanResponse object with the following structure:

{
  receiptno: string; // Receipt/invoice number
  shopname: string; // Store/shop name
  date: string; // Date in ISO format (YYYY-MM-DD)
  time: string; // Time in 24-hour format (HH:MM)
  netAmount: number; // Net amount (before tax)
  grossAmount: number; // Gross amount (total including tax)
  totalItems: number; // Total number of items purchased
  rawInput: string; // Raw OCR text extracted from the image
}

Usage Examples

Basic Usage

import { processReceipt } from "natscan";

const result = await processReceipt("./receipt.jpg");
console.log("Shop:", result.shopname);
console.log("Total:", result.grossAmount);

Advanced Usage

import { OCRPipeline } from "natscan";

const pipeline = new OCRPipeline({
  languages: ["eng", "chi_sim", "chi_tra"],
  preprocessingLevel: "high",
  confidenceThreshold: 0.7,
  debug: true,
});

// Process single receipt
const result = await pipeline.processReceipt("receipt.jpg");

// Process multiple receipts
const results = await pipeline.processBatch([
  "receipt1.jpg",
  "receipt2.jpg",
  "receipt3.jpg",
]);

// Clean up resources
await pipeline.cleanup();

Configuration

Default Configuration

{
  languages: ['eng', 'chi_sim', 'chi_tra'],
  preprocessingLevel: 'medium',
  confidenceThreshold: 0.6,
  debug: false,
}

Configuration Options

interface OCRConfig {
  languages: ("chi_sim" | "chi_tra" | "eng")[];
  preprocessingLevel: "low" | "medium" | "high";
  confidenceThreshold: number; // 0-1
  debug?: boolean;
}

Supported Languages

  • English (eng) - US, UK, international formats
  • Simplified Chinese (chi_sim) - Mainland China formats
  • Traditional Chinese (chi_tra) - Taiwan, Hong Kong formats

Supported Image Formats

  • JPEG (.jpg, .jpeg)
  • PNG (.png)
  • WebP (.webp)
  • TIFF (.tiff, .tif)

Requirements

  • React Native >= 0.81.0 (tested with 0.81)
  • Expo SDK >= 50.0.0 (tested with SDK 54)
  • Node.js >= 18.0.0
  • iOS >= 15.5 (required by ML Kit)
  • Android >= API 21 (Android 5.0)

Documentation

For detailed documentation, please refer to the docs folder:

Development

Build

npm run build

Test

# Interactive test script
npm run test:local

# Unit tests
npm test

Development Mode

npm run dev

Performance

  • Average processing time: 2-5 seconds per receipt
  • Accuracy: 85-95% on clear, well-lit receipts
  • Image requirements:
    • Minimum width: 800px
    • Supported formats: JPG, PNG, WEBP, TIFF
    • Recommended: Good lighting, minimal blur

License

MIT

Support

For issues and questions, please refer to the Troubleshooting guide or open an issue on the repository.