Image to Text OCR with Tesseract.js
Extract text from images using javascript
Are you looking to extract text from images, photos? Did you just take a picture of the lecture notes and want to convert it into text? Then you’ll need an application that can recognize text via OCR (Optical Character Recognition).
Today, I am going to fulfill your long-awaited wish, to build an image to text converter with the powerful JavaScript library Tesseract.js

Try it yourself in the link below:
Implementation
Did you just feel like you had discovered the treasure? We could get a scanned image of a book, and use OCR tech to read the image, and output text in a format we can use on a machine. This could drastically improve our productivity, and it avoids duplicate manual entry.
In this tutorial, I’ll show you how to use Tesseract.js to build an OCR web application. Let’s jump straight into the code.
# Step 1: Include tesseract.js
First of all, we need to include the JavaScript library tesseract.js. The easiest way to include Tesseract.js in your HTML5 page is to use a CDN. So, add the following to the <head> of your webpage.
<html>
<head>
<script src='https://unpkg.com/[email protected]/dist/tesseract.min.js'></script>
</head>If you are using npm, you can also install it by running the command below
npm install tesseract.js@nextAt the end of the , include the main javascript file tesseract-ocr.js
<script src="js/tesseract-ocr.js"></script>
</body>
</html># Step 2: Set up html element
The next thing we will need to do is to add the html elements below
- Language selector
- Image File selector
- Thumbnail preview of image selected
- Placeholder of results after processing





