How to create 2D barcodes
IronBarcode enables you to generate all major 2D barcode formats including QR Code, Aztec, DataMatrix, MaxiCode, PDF417, and the new rMQR format with simple C# code. Simply pass the desired encoding type to the CreateBarcode method and export as an image. With support for over 30 barcode formats, IronBarcode provides a comprehensive solution for all your barcode generation needs.
When storing detailed information in a small space, 2D barcodes are the definitive industry solution. They hold thousands of characters while remaining readable even when torn, scratched, or marked. Because they can be scanned from any angle and don't require perfect alignment, these barcodes are ideal for fast-paced logistics and mobile scanning applications. Built-in error correction ensures your data remains accessible even in challenging conditions.
The main challenge is selecting the correct format for your specific needs. You might need Aztec Code's borderless compact design for mobile ticketing, DataMatrix's industrial precision for tiny electronic components, or PDF417's massive offline storage capacity for driver's licenses and ID cards. With IronBarcode, you can generate all these formats reliably and efficiently.
In this guide, we'll cover how to generate critical 2D formats like QR Code, MaxiCode, and the new rMQR, along with their everyday use cases.
Quickstart: Generate Your First 2D Barcode
Use IronBarcode's simple API to create a QR Code from a string and save it as a PNG image. Get started immediately - supply the data, choose the encoding and size, and write your image file.
-
1Install IronBarcode with NuGet Package Manager
-
2Copy and run this code snippet.
IronBarCode.BarcodeWriter.CreateBarcode("Hello World", BarcodeEncoding.QRCode, 250, 250).SaveAsPng("myQRCode.png");C# -
3Deploy to test on your live environment
Start using IronBarcode in your project today with a free trial
How to Create 2D Barcodes with IronBarcode
- Download the IronBarcode C# library to create barcodes
- Generate a barcode with a string value with
CreateBarcode - Specify the barcode type with
BarcodeEncoding - Save the barcode as an image or other format with
SaveAsJpeg
What are 2D barcodes and when should I use them?
Two-dimensional barcodes like QR Codes use a grid of squares or dots to store information both horizontally and vertically. In contrast, linear one-dimensional barcodes use a single row of lines to store data. While standard barcodes hold only a few numbers or letters, 2D codes can store massive amounts of data - including web links, ID details, or entire files - without requiring a database connection.
This robust design makes 2D barcodes incredibly durable. Built-in error correction allows scanning even when barcodes are scratched, torn, or marked, where typical barcodes would fail. This makes 2D barcodes ideal for harsh environments or mobile scanning where perfect conditions aren't guaranteed. For more information on fine-tuning error correction, see our error correction guide.
Let's explore all 2D barcode formats supported by IronBarcode, demonstrate how to create them, and discuss their common uses. Each format has unique characteristics suited to specific applications.
How do I create an Aztec barcode for mobile ticketing?
Aztec Code is a high-density 2D matrix recognized by its square bullseye pattern at the center. Unlike other formats, Aztec codes are space-efficient and store data in a compact square format.
Aztec code's unique advantage is that it requires no quiet zone, unlike other barcodes. It's commonly used for mobile ticketing like electronic boarding passes and healthcare patient wristbands. Airlines and transit systems prefer this format for its compact size and excellent readability on smartphone screens.
Code
IronBarcode makes generating Aztec codes simple: pass BarcodeEncoding.Aztec as the second parameter when calling the CreateBarcode method, then export the result as an image. You can further customize the appearance using IronBarcode's styling options.
using IronBarCode;
// Create the Aztec barcode
GeneratedBarcode AztecCode = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode/", BarcodeEncoding.Aztec);
// Display the value below the barcode
AztecCode.AddBarcodeValueTextBelowBarcode();
// Save as a JPG file
AztecCode.SaveAsJpeg("aztec-sample.jpg");Imports IronBarCode
' Create the Aztec barcode
Dim AztecCode As GeneratedBarcode = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode/", BarcodeEncoding.Aztec)
' Display the value below the barcode
AztecCode.AddBarcodeValueTextBelowBarcode()
' Save as a JPG file
AztecCode.SaveAsJpeg("aztec-sample.jpg")Output

How do I create a DataMatrix barcode for industrial part marking?
Data Matrix is a compact 2D matrix recognized by the L-shaped finder pattern on its perimeter. This format excels where space is limited and durability is critical.
Data Matrix's unique strength is extreme durability and ability to scale down to microscopic sizes for direct part marking (DPM). It's commonly used for industrial tracking on surgical instruments, electronic components, and aerospace parts where space is severely limited. The format's compact size and high data density are perfect for creating barcodes from various data types including serial numbers and batch codes.
Code
IronBarcode makes generating DataMatrix codes simple: pass BarcodeEncoding.DataMatrix as the second parameter when calling the CreateBarcode method, then export the result as an image.
using IronBarCode;
// Create the DataMatrix barcode
GeneratedBarcode DataMatrix = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode/", BarcodeEncoding.DataMatrix);
// Display the value below the barcode
DataMatrix.AddBarcodeValueTextBelowBarcode();
// Save as a JPG file
DataMatrix.SaveAsJpeg("dataMatrix-sample.jpg");Imports IronBarCode
' Create the DataMatrix barcode
Dim DataMatrix As GeneratedBarcode = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode/", BarcodeEncoding.DataMatrix)
' Display the value below the barcode
DataMatrix.AddBarcodeValueTextBelowBarcode()
' Save as a JPG file
DataMatrix.SaveAsJpeg("dataMatrix-sample.jpg")Output

How do I create a MaxiCode barcode for shipping labels?
MaxiCode is a fixed-size 2D matrix recognized by its circular bullseye pattern surrounded by a hexagonal grid. This unique design was engineered specifically for high-speed scanning on conveyor belts.
MaxiCode's unique aspect is its constant 1-inch physical size regardless of stored data, optimizing it for high-speed conveyor belt reading. It's commonly used in logistics and supply chain management, specifically on UPS shipping labels for automated package sorting and routing. The fixed size ensures consistent scanning performance regardless of data payload.
Code
IronBarcode makes generating MaxiCode simple: pass BarcodeEncoding.MaxiCode as the second parameter when calling the CreateBarcode method, then export it as an image. For more examples, check our barcode quickstart guide.
using IronBarCode;
// Create the MaxiCode barcode
GeneratedBarcode MaxiCode = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode/", BarcodeEncoding.MaxiCode);
// Display the value below the barcode
MaxiCode.AddBarcodeValueTextBelowBarcode();
// Save as a JPG file
MaxiCode.SaveAsJpeg("maxiCode-sample.jpg");Imports IronBarCode
' Create the MaxiCode barcode
Dim MaxiCode As GeneratedBarcode = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode/", BarcodeEncoding.MaxiCode)
' Display the value below the barcode
MaxiCode.AddBarcodeValueTextBelowBarcode()
' Save as a JPG file
MaxiCode.SaveAsJpeg("maxiCode-sample.jpg")Output

How do I create a PDF417 barcode for ID cards?
PDF417 is a stacked linear barcode recognized by its wide, rectangular appearance resembling digital static. This format encodes significantly more data than other 2D formats, making it ideal for storing detailed information.
PDF417's unique capability is serving as a portable data file, storing large amounts of data like photos, names, and biometric records without requiring database connections. It's commonly used for government identification like driver's licenses and printed airline boarding passes. The format supports both text and binary data encoding.
Code
IronBarcode makes generating PDF417 simple: pass BarcodeEncoding.PDF417 as the second parameter when calling the CreateBarcode method, then export it as an image. You can also save barcodes in various image formats including PNG, JPEG, and more.
using IronBarCode;
// Create PDF417 barcode
GeneratedBarcode PDF417code = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode/", BarcodeEncoding.PDF417);
// Display the value below the barcode
PDF417code.AddBarcodeValueTextBelowBarcode();
// Save as a JPG file
PDF417code.SaveAsJpeg("pdf417-sample.jpg");Imports IronBarCode
' Create PDF417 barcode
Dim PDF417code As GeneratedBarcode = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode/", BarcodeEncoding.PDF417)
' Display the value below the barcode
PDF417code.AddBarcodeValueTextBelowBarcode()
' Save as a JPG file
PDF417code.SaveAsJpeg("pdf417-sample.jpg")Output

How do I create a QR Code for marketing campaigns?
A QR Code is a high-density 2D matrix recognized by three distinctive square finder patterns in its corners. As the most widely recognized 2D barcode format, QR codes have become ubiquitous in consumer applications.
QR Code's unique advantage is universal consumer accessibility - it's the only 2D symbology natively supported by virtually all modern smartphone camera apps without additional software. It's commonly used for marketing and public engagement, linking to websites and digital menus, and facilitating mobile payments. For advanced QR code generation, explore our QR code creation examples.
Code
IronBarcode makes generating QR codes simple: pass BarcodeEncoding.QRCode as the second parameter when calling the CreateBarcode method, then export it as an image. You can also customize QR code styles by adding logos and changing colors.
using IronBarCode;
// Create QR Code
GeneratedBarcode QRcode = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode/", BarcodeEncoding.QRCode);
// Display the value below the barcode
QRcode.AddBarcodeValueTextBelowBarcode();
// Save as a JPG file
QRcode.SaveAsJpeg("QRcode.jpg");Imports IronBarCode
' Create QR Code
Dim QRcode As GeneratedBarcode = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode/", BarcodeEncoding.QRCode)
' Display the value below the barcode
QRcode.AddBarcodeValueTextBelowBarcode()
' Save as a JPG file
QRcode.SaveAsJpeg("QRcode.jpg")Output

How do I create a Micro QR Code for small electronics?
A Micro QR Code is a miniaturized 2D matrix recognized by its single square finder pattern in the top-left corner. This format was designed specifically for applications where space is extremely limited.
Due to its miniaturized size, character limits apply. The largest version (M4) holds a maximum of 21 alphanumeric characters or 35 numbers. Carefully plan your data encoding strategy when using Micro QR codes.
Code
IronBarcode makes generating MicroQRCode simple: pass BarcodeEncoding.MicroQRCode as the second parameter when calling the CreateBarcode method, then export it as an image.
using IronBarCode;
// Create a Micro QR Code
GeneratedBarcode microQRcode = BarcodeWriter.CreateBarcode("IRON-1234", BarcodeEncoding.MicroQRCode);
// Display the value below the barcode
microQRcode.AddBarcodeValueTextBelowBarcode();
// Save to file as Jpeg
microQRcode.SaveAsJpeg("microQRCode.jpg");Imports IronBarCode
' Create a Micro QR Code
Dim microQRcode As GeneratedBarcode = BarcodeWriter.CreateBarcode("IRON-1234", BarcodeEncoding.MicroQRCode)
' Display the value below the barcode
microQRcode.AddBarcodeValueTextBelowBarcode()
' Save to file as Jpeg
microQRcode.SaveAsJpeg("microQRCode.jpg")Output

What happens if my data exceeds Micro QR capacity?
IronBarcode throws an error if the input string exceeds 35 numeric digits or 21 alphanumeric characters. This built-in validation helps prevent runtime errors in production environments.

How do I create an rMQR Code for narrow spaces?
Rectangular Micro QR Code (rMQR) is a specialized 2D matrix recognized by its elongated, strip-like shape and single finder pattern in the top-left corner. This innovative format addresses a specific gap in barcode technology.
Due to its rectangular design, it stretches horizontally to increase capacity without increasing vertical footprint. The largest version (R17x139) contains up to 219 alphanumeric characters or 361 numbers - significantly more capable than MicroQRCode while maintaining a slim profile.
Code
IronBarcode makes generating RMQRCode simple: pass BarcodeEncoding.RMQRCode as the second parameter when calling the CreateBarcode method, then export it as an image. For a comprehensive overview of all IronBarcode features, visit our API reference.
using IronBarCode;
// Create a RmQR Code
GeneratedBarcode rMqrCode = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode/", BarcodeEncoding.RMQRCode);
// Display the value below the barcode
rMqrCode.AddBarcodeValueTextBelowBarcode();
// Save to file as Jpeg
rMqrCode.SaveAsJpeg("rmQRcode.jpg");Imports IronBarCode
' Create a RMQR Code
Dim rMqrCode As GeneratedBarcode = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode/", BarcodeEncoding.RMQRCode)
' Display the value below the barcode
rMqrCode.AddBarcodeValueTextBelowBarcode()
' Save to file as Jpeg
rMqrCode.SaveAsJpeg("rmQRcode.jpg")Output

What happens if my data exceeds rMQR capacity?
IronBarcode throws an error if the input string exceeds 361 numeric digits or 219 alphanumeric characters. This validation ensures your barcodes remain scannable and compliant with the rMQR specification.

Which 2D barcode format should I choose?
| Name | Format | Common Usage | Restrictions & Pitfalls |
|---|---|---|---|
| Aztec Code | Matrix (Center-Out) Square grid with central "bullseye" finder. No quiet zone required. | Mobile boarding passes (Apple Wallet), train tickets, and healthcare wristbands. |
|
| Data Matrix | Matrix (L-Pattern) Square or rectangular with solid "L" border on two sides. | Electronics components, surgical instruments, and Direct Part Marking (DPM) on metal. |
|
MaxiCode | Fixed Size Matrix Exactly 1x1 inch. Hexagonal dots with central circular bullseye. | UPS Shipping labels and high-speed conveyor belt sorting. |
|
PDF417 | Stacked Linear Wide rectangle resembling digital static. High capacity. | Driver's Licenses (AAMVA), ID cards, and paper boarding passes. |
|
| QR Code | Matrix Square with three distinctive corner finder patterns. | Consumer marketing, payments, restaurant menus, Wi-Fi pairing. |
|
| Micro QR | Miniature Matrix Tiny square with only one corner finder pattern. | Printed Circuit Boards (PCBs), small electrical components. |
|
rMQR | Rectangular Matrix Long, narrow strip bridging Micro QR and standard QR. | Test tubes, cables, thin bezels, narrow product edges. |
|
Frequently Asked Questions
What are 2D barcodes and when should I use them?
2D barcodes, like QR Codes and Data Matrix, use a grid of squares or dots to store information horizontally and vertically. These codes can store large amounts of data, such as URLs and ID details, and are highly durable due to built-in error correction. They're ideal for environments where barcodes may be scratched or damaged, or where quick scanning is necessary.
How do I create a QR Code using IronBarcode?
To create a QR Code using IronBarcode, use the `CreateBarcode` method, passing `BarcodeEncoding.QRCode` as a parameter, and export the barcode as an image with methods like `SaveAsJpeg`. IronBarcode allows you to customize the QR code by adding logos and changing colors.
Can IronBarcode generate Aztec barcodes for mobile ticketing?
Yes, IronBarcode can generate Aztec barcodes. By using the `BarcodeEncoding.Aztec` parameter in the `CreateBarcode` method, you can create this compact, space-efficient barcode, which is ideal for applications like mobile ticketing and electronic boarding passes.
What is the advantage of using Data Matrix barcodes with IronBarcode?
Data Matrix barcodes are extremely durable and can be scaled to microscopic sizes, making them ideal for industrial applications and direct part marking on electronic components. IronBarcode simplifies their creation with easy-to-use methods and options for customizing appearance.
How can I create a MaxiCode barcode with IronBarcode for logistics purposes?
To create a MaxiCode barcode with IronBarcode, pass `BarcodeEncoding.MaxiCode` to the `CreateBarcode` method. MaxiCode barcodes are optimized for high-speed scanning on logistics conveyor belts and have a fixed size, which is advantageous for automated sorting and routing.
Is IronBarcode capable of creating PDF417 barcodes for ID cards?
Yes, IronBarcode can create PDF417 barcodes, which are perfect for storing large amounts of data such as text and biometric records. Use `BarcodeEncoding.PDF417` in the `CreateBarcode` method, and export the result in various image formats for use on ID cards and licenses.
Can I generate Micro QR Codes using IronBarcode?
IronBarcode supports the generation of Micro QR Codes, which are designed for applications with limited space. Use `BarcodeEncoding.MicroQRCode` when calling `CreateBarcode`, but ensure your data doesn't exceed the character limits specific to Micro QR Codes.
What happens if my data exceeds the capacity of an rMQR Code when using IronBarcode?
IronBarcode will throw an error if the input string for an rMQR Code exceeds 361 numeric digits or 219 alphanumeric characters, ensuring your barcodes remain scannable and compliant with specifications.
How do I choose the right 2D barcode format with IronBarcode?
Choosing the right 2D barcode with IronBarcode involves understanding each format's strengths. Aztec is great for mobile screens, DataMatrix for industrial marking, QR for consumer use, and so on. IronBarcode supports all these, offering customization for specific needs.
What makes 2D barcodes generated by IronBarcode reliable?
IronBarcode equips 2D barcodes with built-in error correction, maintaining data accessibility even if the barcode is damaged. This feature, alongside the capacity to store large amounts of data, makes them reliable for fast-paced and mobile scanning environments.

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.