NewConnect Claude, Gemini, ChatGPT, and other AI agents to API Ninjas via our MCP server

Image to Text API

The Image to Text API detects and extracts text from images using state-of-the-art optical character recognition (OCR) algorithms. It can detect texts of different sizes, fonts, and even handwriting.

(4.5)

From 7,083 users

3,400+

Applications using this API

API Status

Online - All Systems Operational

API Response Times

Average
P50
P75
P90
P95
301ms338ms373ms672ms1130ms

Didn't find what you were looking for? Suggest an improvement


/v1/imagetotext POST

https://api.api-ninjas.com/v1/imagetotext

Given an input image, return all detected texts and their bounding boxes.

PlanImage Size Limit
Free200KB per image
PremiumUp to 5MB per image

Files

  • image  required

    Image file to extract text from. Must be either JPEG or PNG format.

Headers

  • X-Api-Key  required

    API Key associated with your account.

Sample Request Live Demo!

input-image

Try our APIs in the API playground

Sign up for a free API key to get started — no credit card required.

https://api.api-ninjas.com/v1/imagetotext

Headers

X-Api-KeyLog in or sign up to get your API Key

Sample Response

JSON
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 [ { "text": "API", "bounding_box": { "x1": 60, "y1": 72, "x2": 163, "y2": 118 } }, { "text": "Ninjas", "bounding_box": { "x1": 189, "y1": 72, "x2": 373, "y2": 132 } }, { "text": "Image", "bounding_box": { "x1": 64, "y1": 178, "x2": 170, "y2": 215 } } ] ...

Code Examples

1 2 3 curl -X POST "https://api.api-ninjas.com/v1/imagetotext" \ -H "X-Api-Key: YOUR_API_KEY" \ -F "image=@YOUR_IMAGE.jpeg"

If your programming language is not listed in the Code Example above, you can still make API calls by using a HTTP request library written in your programming language and following the above documentation.

Frequently Asked Questions

  • Yes, but you must have a premium subscription. Commercial use of the Image to Text API is not permitted on the free tier. See our pricing page to choose a plan that fits your needs.
  • Sign up for a free account to instantly get your API key, then pass it in the X-Api-Key header on every request. The documentation above includes ready-to-run examples in cURL, Python, JavaScript, Node.js, and more.
  • Your API requests will simply be denied once you hit your monthly quota — you will never be charged more than the plan you signed up for. To increase your quota, you can upgrade your plan any time on our pricing page.
  • The API responds with a standard HTTP status code and a JSON error message describing the problem. See our error codes reference for the full list of codes and how to resolve each one, or contact support if you need help.
  • The Image to Text API uses state-of-the-art OCR to detect and extract text of different sizes, fonts, and even handwriting from images, making it useful for digitizing scanned documents, reading receipts and signs, and automating data entry. It pairs well with other vision tools like our Object Detection and Face Detect APIs.
  • Send a POST request to the /v1/imagetotext endpoint with the image attached as a multipart form file named image; it must be in JPEG or PNG format. See the API documentation for full code examples in multiple languages.
  • The response returns all detected text strings along with their bounding box coordinates, so you can both read the extracted text and locate where each piece appears in the image. If a request returns an error, refer to our error codes page.
  • Free accounts can upload images up to 200KB each, while premium accounts can submit images up to 5MB each. See our pricing page to compare plans, or register to get started.