A new TypeScript library extends in-browser OCR by decoupling detection and recognition stages, enabling customisable, privacy-preserving document processing.
Running OCR in the browser has one clear advantage: the document never has to leave the device. That privacy-first model has already been used in browser-based tools such as SnapPDF and MedSpeak, both of which keep images local while extracting text with client-side OCR. The latest work on @stabrise/scaledp extends that idea by making OCR more modular, so detection and recognition can be mixed rather than locked together.
According to the developer’s account, the library is a TypeScript port of ScaleDP, with a pipeline built from stages that pass structured data from one step to the next. It already supported PDF rendering, OCR and named-entity recognition entirely in the browser through onnxruntime-web. The problem was that its PaddleOCR-based recogniser performed detection and reading in a single pass, which meant boxes found by another detector could not be handed into the text reader.
The answer was a new stage called PaddleRecognizer, which accepts an image and a set of boxes and returns a document. That makes it possible to pair PaddleOCR’s recognition model with other detectors, including DBNet or a YOLO-based signature detector, without re-running detection each time. In practical terms, the pipeline can now detect text once and then compare different recognition presets against the same regions.
The implementation had to deal with several non-obvious constraints. Crops are now perspective-warped before recognition so rotated text is read in the correct orientation. The recogniser also batches multiple crops onto a single canvas, because onnxruntime-web only benefits from batching when boxes are processed together in one call. And when WebGPU fails on the recogniser’s graph, the code can fall back to WASM, although that option is disabled by default so genuine configuration errors still fail loudly.
The refactor also exposed a separate problem in the earlier word-splitting logic. Instead of chopping a line into words before recognition, the new approach reads the whole line first and then reconciles the model’s output with ink gaps in the image. The developer says that change reduced dropped characters and improved awkward cases such as signatures, where character-level cropping had previously produced distorted, box-heavy output rather than faithful geometry.
The result is less like a generic abstraction layer and more like a carefully composed document pipeline. Each stage keeps the engine-specific parameters it needs, while composability comes from shared column names and schemas. That design also fits the library’s failure handling: stages return structured errors rather than throwing by default, which is safer for batch processing pages in a browser context where one bad crop should not break the rest of the document.
Disclaimer: This content is intended for informational purposes only. Readers are advised to exercise their own judgement, conduct due diligence, or consult a qualified expert before acting on any information provided.





