How to Read MICR Cheque using IronOCR

Manually processing checks is slow and error-prone. IronOCR streamlines this workflow with a specialized engine that accurately reads the MICR (Magnetic Ink Character Recognition) line, letting you automate the extraction of routing numbers, account numbers, and other critical data.

This guide provides a step-by-step tutorial on using the IronOCR library to perform MICR reading on a sample check image, enabling faster and more reliable financial processing in your .NET applications.

Get Started with IronOCR

Start using IronOCR in your project today with a free trial.

First Step:
green arrow pointer


To use this function, you must also install the IronOcr.Languages.MICR package.

Read MICR Cheque Example

Reading a MICR line with IronOCR is simple and intuitive. We begin by setting the Language property of the IronTesseract instance to OcrLanguage.Micr. To ensure the engine reads the correct area, it is necessary to specify the location of the MICR line by setting a rectangular boundary on the OcrInput.

This is achieved by selecting the x and y coordinates, as well as the height and width of the bounding box rectangle, and then passing the rectangle as the second parameter when calling the Load method. Calling the Read method then processes only this defined region. This combination of the MICR language setting and a specific region guarantees that IronOCR accurately extracts the relevant financial information.

Cheque Input

MICR Cheque

The MICR Line

Check Number: This number uniquely identifies the specific cheque from the account holder's checkbook. It serves as a clear reference for tracking individual payments and maintaining transaction records.

Routing Number: This nine-digit code, enclosed by the ⑆ transit symbol, identifies the financial institution that holds the account. It's the first piece of information a clearinghouse uses to direct the cheque to the correct bank for payment.

Account Number: This identifies the specific customer account from which funds will be drawn. Its length can vary between different banks.

Code

:path=/static-assets/ocr/content-code-examples/how-to/read-micr-cheque.cs
using IronOcr;
using IronSoftware.Drawing;
using System;

// Create a new instance of IronTesseract for performing OCR operations
IronTesseract ocr = new IronTesseract();

// Set the OCR language to MICR to recognize magnetic ink characters
// Must have MICR (IronOcr.Languages.MICR) installed beforehand
ocr.Language = OcrLanguage.MICR;

// Specify the file path of the input image containing MICR text
using (var input = new OcrInput())
{
    // Specify the MICR of the image to focus on for OCR (coordinates in pixels)
    var contentArea = new Rectangle(x: 215, y: 482, width: 520, height: 20);
    input.LoadImage("micr.png", contentArea);

    // Optional: Save the cropped area for verification
    input.StampCropRectangleAndSaveAs(contentArea, Color.Aqua, "cropped.png");

    // Run the OCR engine to read the MICR text from the input image
    var result = ocr.Read(input);
    // Output the recognized text to the console
    Console.WriteLine(result.Text);

    // Transit number is the first 7 characters of the MICR string
    string transitNum = result.Text.Substring(0, 7);
    // Routing number starts from the 8th character and is 11 characters long
    string routingNum = result.Text.Substring(7, 11);
    // Account number starts from the 22nd character to the end of the string
    string accountNum = result.Text.Substring(22);
}
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Output

MICR Output

The output above showcases the three sections obtained from the MICR cheque: the transit number, the routing number, and the account number.

MICR OCR Results

The OcrResult object provides detailed information about the scan:

Text: The extracted text from OCR Input.

Confidence: Indicates the statistical accuracy confidence of an average of every character, with one being the highest and zero being the lowest.

Verifying the OCR region of the MICR Cheque

To ensure you've selected the correct coordinates for the MICR line, you can visualize the ContentArea you defined. A simple way to do this is to draw the rectangle on the input image and save it as a new file with StampCropRectangleAndSaveAs. This helps you debug and fine-tune the coordinates for optimal performance.

TipsTo find the coordinates for your Rectangle, you can use a simple image editor like MS Paint. Open your cheque image, hover your mouse over the top-left and bottom-right corners of the MICR line, and note the (x,y) pixel coordinates. You can then calculate the rectangle's properties: (x1, y1, width, height), where width = x2-x1 and height = y2-y1.

Here is the output image after drawing the specified bounding box on our example cheque.

Output

MICR cropped

The light blue rectangle confirms that we have correctly isolated the MICR line for processing.

Curtis Chau
Technical Writer

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.

...Read More

Ready to Get Started?
Nuget Downloads 4,685,233 | Version: 2025.10 just released