Free JavaScript Library to Parse Text from Scanned Images & Forms
Open Source Optical Character Recognition (OCR) JavaScript library for Parsing Text from Black-&-White Scanned Images & Documents with Image Preprocessing & Templates Support in Web or Node.js Apps.
In the modern digital world, optical character recognition (OCR) technology plays a critical role in transforming scanned images, handwritten notes, or printed documents into editable and searchable data. For JavaScript developers looking for a lightweight and open-source solution, Guten OCR offers a compelling choice. This JavaScript-based OCR engine is designed with simplicity in mind, making it ideal for embedding OCR features directly into browser-based or Node.js applications. There are several important features part of the library, such as character recognition via templates, image thresholding and binarization, character segmentation, template matching and text assembly, modular codebase support and so on. It focuses on recognizing printed text from black-and-white scanned documents and is best suited for well-formatted text, such as books or forms.
Guten OCR is an open-source JavaScript OCR engine created by Gutenye. Unlike heavyweight OCR tools that require external dependencies or extensive setup, Guten OCR is written entirely in JavaScript, meaning it can run in a web browser or on the server with Node.js. The library uses basic image processing techniques to segment characters and identify them using a character pattern recognition system. While it may not yet compete with commercial OCR engines like Tesseract in terms of multilingual or handwritten text support, its simplicity and hackability make it a fantastic option for educational projects, proof-of-concepts, or embedded OCR features in custom web apps. Unlike Tesseract or other larger engines, Guten OCR is intentionally lightweight and focused—making it an excellent starting point for those who want to understand how OCR works under the hood.
Getting Started with Guten OCR
The recommend way to install Guten OCR is using Brew. Please use the following command for a smooth installation
Install Guten OCR via Brew
brew install git-lfs
Install Guten OCR via GitHub
git clone git@github.com:gutenye/ocr.git
You can also install it manually; download the latest release files directly from GitHub repository.
Image Preprocessing Before OCR Operations
The open source Guten OCR library is written entirely in JavaScript, making it compatible with both browser and Node.js environments. It includes built-in image preprocessing functions to enhance recognition accuracy. It supports image Binarization (converting to black and white), noise reduction, skew correction and more. The following example shows how developers can apply multiple image preprocessing steps before performing OCR operation on images.
How to Apply Image Preprocessing before OCR Operation via JavaScript Library?
const { preprocess } = require('guten-ocr');
// Apply multiple preprocessing steps
const processedImage = preprocess(imageData, [
'grayscale', // Convert to grayscale
'binarize', // Convert to black and white
'deskew', // Correct skew
'denoise' // Reduce noise
]);
// Then perform OCR on the processed image
ocr.recognize(processedImage).then(/* ... */);
Character Recognition via Templates
The JavaScript library Guten OCR has provided complete support for performing OCR operations using templates inside JavaScript applications. At the heart of Guten OCR is a template-matching system. Instead of training a machine learning model, it uses predefined character patterns. This makes the system faster and easier to understand but more sensitive to font and layout consistency. To perform this task the library render each character (A–Z, a–z, 0–9, etc.) in a canvas and then binary matrix for each character becomes a reference template. When analyzing an image, the library compares image segments against these templates to find the best match. It does this using a combination of vertical and horizontal line scanning to locate bounding boxes.
Character Segmentation via OCR Library
The open source JavaScript library Guten OCR enables software developers to perform character segmentation with ease. Once the image is binarized, the next step is segmenting individual characters. Guten OCR scans rows and columns to detect regions with dense black pixels, separating them into potential characters. The following example demonstrates, how software developers can perform character segmentation using JavaScript OCR library.
How to Perform Character Segmentation using JavaScript Library?
const segment = require('guten-ocr/segment');
const boxes = segment(binarized); // returns array of [x, y, width, height]