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

ffocr

v0.1.11

Published

Browser-first PaddleOCR wrapper powered by ONNX Runtime Web with automatic WebGPU/WASM selection.

Downloads

842

Readme

ffocr

Browser OCR for frontend apps using PaddleOCR models converted to ONNX.

npm: https://www.npmjs.com/package/ffocr

Live Demo: https://zxc88645.github.io/ffocr/demo/

Install

npm install ffocr

Quick start

If you want the built-in hosted model:

import { createDefaultPPOcrV5 } from "ffocr";

const ocr = createDefaultPPOcrV5();
const result = await ocr.ocr(fileOrBlobOrUrl);
console.log(result.text);

If you want to host the model files yourself:

import { createPPOcrV5 } from "ffocr";

const ocr = createPPOcrV5({
  baseUrl: "https://your-cdn.example.com/models/pp-ocrv5"
});

const result = await ocr.ocr(fileOrBlobOrUrl);
console.log(result.text);

Model variant

PP-OCRv5 ships two model variants: mobile (default) and server. The mobile variant is smaller and faster, while server offers higher accuracy at a larger size.

// Uses the default mobile model
const ocr = createDefaultPPOcrV5();

// Switch to the server model
const ocr = createDefaultPPOcrV5({ modelVariant: "server" });

The same option works with a custom baseUrl:

const ocr = createPPOcrV5({
  baseUrl: "https://your-cdn.example.com/models/pp-ocrv5",
  modelVariant: "server"
});

Model caching

Enable cacheModels to persist downloaded models in the browser's Cache API. Subsequent page loads will read from cache instead of re-downloading:

const ocr = createDefaultPPOcrV5({ cacheModels: true });

Progress callback

Track loading, download, and inference progress via onProgress:

const result = await ocr.ocr(file, {
  onProgress({ phase, current, total, loaded, totalBytes }) {
    // phase: "loading_dictionary" | "loading_detection_model"
    //      | "loading_recognition_model" | "warmup"
    //      | "preprocessing" | "detecting" | "recognizing"
    if (loaded != null && totalBytes != null) {
      const pct = Math.round((loaded / totalBytes) * 100);
      console.log(`${phase}: ${pct}%`);
    } else if (phase === "recognizing") {
      console.log(`Recognizing ${current}/${total}`);
    } else {
      console.log(phase);
    }
  }
});

Main API

createDefaultPPOcrV5(options?)

Creates an OCR instance using the package default hosted model URL.

ocrWithDefaultPPOcrV5(source, options?, ocrOptions?)

One-shot OCR helper using the package default hosted model URL.

createPPOcrV5({ baseUrl, ...options })

Recommended when you want full control over model hosting.

ocrWithPPOcrV5(source, options, ocrOptions?)

One-shot OCR helper for a custom baseUrl.

createPaddleOcr({ manifest, ...options })

Lower-level API for custom manifests or model paths.

Required model files

Your baseUrl should point to a folder that contains the detection and recognition ONNX pair for the variant you use (mobile by default):

  • Mobile: det_mobile.onnx, rec_mobile.onnx
  • Server: det_server.onnx, rec_server.onnx

Override filenames with detectionModelPath / recognitionModelPath if your layout differs.

Dictionary: By default the dictionary is loaded from the PaddleOCR project (not from baseUrl). To self-host it, set dictionaryUrl to your ppocrv5_dict.txt URL.

Default model URL

createDefaultPPOcrV5 loads weights from:

https://zxc88645.github.io/ffocr/models/pp-ocrv5

Use createPPOcrV5 with your own baseUrl when you need to self-host or pin assets.

The bundled conversion flow patches the generated ONNX files so the default PP-OCRv5 models stay compatible with ONNX Runtime WebGPU.

Supported inputs

  • ImageData
  • ImageBitmap
  • HTMLImageElement
  • HTMLCanvasElement
  • OffscreenCanvas
  • Blob
  • string URL

Runtime

  • Detects available ONNX Runtime Web execution providers including webgpu, webnn, webgl, and wasm
  • In auto mode, picks the first available provider in this order: webgpu -> webnn -> webgl -> wasm

Extra docs