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.
How to Read MICR cheques using IronOCR
- Download the C# library for reading MICR cheques
- Instantiate the OCR engine
- Set the
Language
setting to MICR - Use the
Read
method to extract data from the sample cheque image - Access the OcrResult property to view and manipulate the extracted data
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
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
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.
Here is the output image after drawing the specified bounding box on our example cheque.
Output

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