Convert a Photo of a Document into Text using JavaScript

These days it’s common for people to upload important physical documents to the internet (including tax forms, medical records, etc.) by taking a photo of the document, rather than by scanning it in a traditional scanner. If your website is accumulating that type of content from your users, you’ve probably noticed that people don’t always take perfect images, which makes the process of using OCR to pull text from that document rather difficult. Our Photo to Text OCR API is designed specifically to handle such photographed documents, and with its help your application will be able to work around various imperfections in the shot.

To structure your API call with JavaScript, start by installing the jQuery Library. Let’s run the below command:

bower install jquery

After that, let’s include the code snippets to call the OCR API:

var form = new FormData();
form.append("imageFile", fileInput.files[0], "file");
var settings = {
"url": "",
"method": "POST",
"timeout": 0,
"headers": {
"recognitionMode": "<string>",
"language": "<string>",
"Content-Type": "multipart/form-data",
"processData": false,
"mimeType": "multipart/form-data",
"contentType": false,
"data": form
$.ajax(settings).done(function (response) {

And that’s it — no further code required.

Make sure to include your API key where indicated in the documentation — if you don’t have one currently, register for a free account on our website (Home — Cloudmersive APIs) and you’ll receive one shortly thereafter.




There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Day-4 challange

Migration Helper

How To: Contextual Hooks in TypeScript

Angular CLI update issues: Manually Update your Angular Project

The Road to Node via The Express Expressway

Implementing Access Control in Node.JS

How web performance, CSS Grid and PWA are related

7 TypeScript Common Mistakes To Avoid

Person yelling at laptop

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

More from Medium

OCR Preprocessing API: Detect and Unskew a Photo of a Document with JavaScript

Koa.js and How to create Backend with CRUD Operations

ODOO Remote Procedure Calling

How to Install KeyCloak 17 on Windows Machine