How To Set Error Correction

by Hairil Hasyimi Bin Omar

What is Error Correction?

Error Correction in barcodes refer to the extent of its ability to maintain its readability in the presence of visual defects or encoding errors. These damages can arise from various factors such as printing imperfections, smudges, scratches, or variations in scanning conditions. Error correction is one of the major factors for a user to determine which type of barcode encoding is suitable to use.

In general, 2D barcodes have a higher tolerance to defects in comparison to 1D barcodes. This is due to the factors listed below:

  • Data Capacity: 2D barcodes can store significantly more data than 1D barcodes due to ability to encode data both horizontally and vertically, which includes alphanumerics, binary data, images, and more.
  • Redundancy: 2D barcodes have multiple layers of data encoding, which helps in extracting information from the remaining intact sections when the barcode is damaged.
  • Compactness: 2D barcodes are suitable for placing on limited spaces due to its compact shape.
  • Flexibility: 2D barcodes can be scanned from various angles and orientations.


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

First Step:
green arrow pointer

Adjust Error Correction in QR Codes Example

Currently, IronBarcode only supports setting error correction in QR Codes, Micro QRs codes, and rMQRs. IronBarcode supports all four pre-set error correction levels specified by the QR standards. The error correction level can be adjusted with the QrErrorCorrection parameter in the QRCodeWriter.CreateQrCode method. The four levels of error correction are represented as follows:

  • Highest: Level H. Can recover up to 30% of data.
  • High: Level Q. Can recover up to 25% of data.
  • Medium: Level M. Can recover up to 15% of data.
  • Low: Level L. Can recover up to 7% of data.

It's worth noting that higher error correction levels result in more complex QR code images. Therefore, users will need to find a balance between visual clarity and error correction when generating QR codes. The following code sample demonstrates how to set error correction:

:path=/static-assets/barcode/content-code-examples/how-to/set-error-correction.cs
using IronBarCode;

GeneratedBarcode mediumCorrection = QRCodeWriter.CreateQrCode("https://ironsoftware.com/csharp/barcode/", 500, QRCodeWriter.QrErrorCorrectionLevel.Medium);
mediumCorrection.SaveAsPng("mediumCorrection.png");
Imports IronBarCode

Private mediumCorrection As GeneratedBarcode = QRCodeWriter.CreateQrCode("https://ironsoftware.com/csharp/barcode/", 500, QRCodeWriter.QrErrorCorrectionLevel.Medium)
mediumCorrection.SaveAsPng("mediumCorrection.png")
VB   C#

Error Correction Comparison

Below is a sample set of QR Code images, each representing the same value but with varying levels of error correction. As evident, higher levels of error correction result in more complex QR code images, which in turn offer greater fault tolerance.

Highest Error Correction
High Error Correction
Medium Error Correction
Low Error Correction
Hairil related to Error Correction Comparison

Hairil Hasyimi Bin Omar

Software Engineer

Like all great engineers, Hairil is an avid learner. He’s refining his knowledge of C#, Python, and Java, using that knowledge to add value to team members across Iron Software. Hairil joined the Iron Software team from Universiti Teknologi MARA in Malaysia, where he graduated with a Bachelor's degree in Chemical and Process Engineering.