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 Create 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, Data Matrix'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.

Get started with IronBarcode


Quickstart: Generate Your First 2D Barcode

```cs :title=Quick Start using IronBarCode;

// Create a QR Code with one line var myBarcode = BarcodeWriter.CreateBarcode("Hello World", BarcodeEncoding.QRCode);

// Save as image myBarcode.SaveAsPng("myQRCode.png");


1. Install IronBarcode via NuGet: `Install-Package BarCode`
2. Import the namespace: `using IronBarCode;`
3. Create a QR Code: `var myBarcode = BarcodeWriter.CreateBarcode("Hello World", BarcodeEncoding.QRCode);`
4. Save as image: `myBarcode.SaveAsPng("myQRCode.png");`
5. Done! Your QR code is ready to use.

For more detailed installation instructions, visit our [NuGet packages guide](https://ironsoftware.com/csharp/barcode/get-started/advanced-installation-nuget/).

## What are 2D barcodes and when should I use them?

<!-- TODO: Add image here -->
<!-- ![Output showing create 2d barcodes results in IronPDF](/static-assets/images/TODO/create-2d-barcodes-code_output.webp) -->
<!-- Description: Screenshot showing code execution output or results -->

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](https://ironsoftware.com/csharp/barcode/how-to/error-correction/).

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 `Create` method, then export the result as an image. You can further [customize the appearance](https://ironsoftware.com/csharp/barcode/how-to/customize-barcode-style/) using IronBarcode's styling options.

```cs
:path=/static-assets/barcode/content-code-examples/how-to/create-aztec-barcode.cs

Output

Aztec barcode example showing the characteristic bullseye pattern

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 Create method, then export the result as an image.

:path=/static-assets/barcode/content-code-examples/how-to/create-datamatrix-barcode.cs
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");
$vbLabelText   $csharpLabel

Output

DataMatrix barcode example displaying the L-shaped finder pattern

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 Create method, then export it as an image. For more examples, check our barcode quickstart guide.

:path=/static-assets/barcode/content-code-examples/how-to/create-maxicode-barcode.cs
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");
$vbLabelText   $csharpLabel

Output

MaxiCode barcode example with hexagonal pattern and circular bullseye

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 Create method, then export it as an image. You can also save barcodes in various image formats including PNG, JPEG, and more.

:path=/static-assets/barcode/content-code-examples/how-to/create-pdf417-barcode.cs
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");
$vbLabelText   $csharpLabel

Output

PDF417 barcode example showing stacked linear pattern

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 Create method, then export it as an image. You can also customize QR code styles by adding logos and changing colors.

:path=/static-assets/barcode/content-code-examples/how-to/create-QRCode.cs
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");
$vbLabelText   $csharpLabel

Output

QR Code example with three corner finder patterns

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.

Micro QR Code's unique advantage is fitting into extremely tight spaces by reducing overhead, requiring only a two-module quiet zone compared to the standard four, while trading data capacity for physical compactness. It's commonly used for marking small electronic components, printed circuit boards (PCBs), and industrial parts where standard QR Codes are too large.

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 Create method, then export it as an image.

:path=/static-assets/barcode/content-code-examples/how-to/create-microQR.cs
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");
$vbLabelText   $csharpLabel

Output

Micro QR Code example with single finder pattern

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.

Error message displayed when Micro QR Code data capacity is exceeded

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.

rMQR's unique advantage is fitting into long, narrow spaces where square codes cannot—like thin bezel edges or curved surfaces. It bridges the gap between Micro QR's tiny footprint and standard QR Code's high capacity, requiring only a two-module quiet zone. It's commonly used for marking cables, test tubes, medical vials, and thin electronic components where height is severely restricted.

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 Micro QR while maintaining a slim profile.

Code

IronBarcode makes generating RMQRCode simple: pass BarcodeEncoding.RMQRCode as the second parameter when calling the Create method, then export it as an image. For a comprehensive overview of all IronBarcode features, visit our API reference.

:path=/static-assets/barcode/content-code-examples/how-to/create-rmQRcode.cs
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");
$vbLabelText   $csharpLabel

Output

rMQR Code example showing rectangular format

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.

Error message shown when rMQR Code capacity limit is exceeded

Which 2D barcode format should I choose?

NameFormatCommon UsageRestrictions & Pitfalls
Aztec CodeMatrix (Center-Out)
Square grid with central "bullseye" finder. No quiet zone required.
Mobile boarding passes (Apple Wallet), train tickets, and healthcare wristbands.
  • Center Damage: Relies on center finder; bullseye damage causes total failure.
  • Screen Glare: Reflective phone screens can blind standard scanners.
Data MatrixMatrix (L-Pattern)
Square or rectangular with solid "L" border on two sides.
Electronics components, surgical instruments, and Direct Part Marking (DPM) on metal.
  • Quiet Zone: Requires 1-module white border; edge graphics cause failures.
  • Contrast: Shiny metal (DPM) requires specialized lighting to read.
MaxiCodeFixed Size Matrix
Exactly 1x1 inch. Hexagonal dots with central circular bullseye.
UPS Shipping labels and high-speed conveyor belt sorting.
  • Fixed Size: Cannot shrink below 1 inch tall.
  • Printer Quality: Low-resolution thermal printers distort hexagons.
PDF417Stacked Linear
Wide rectangle resembling digital static. High capacity.
Driver's Licenses (AAMVA), ID cards, and paper boarding passes.
  • Truncation: Handheld scanners often miss left/right edges.
  • Size Growth: Physical size increases significantly with more data.
QR CodeMatrix
Square with three distinctive corner finder patterns.
Consumer marketing, payments, restaurant menus, Wi-Fi pairing.
  • Quiet Zone: Requires large white margin (4 modules wide).
  • Density: Long URLs without shortening create unfocusable "static".
Micro QRMiniature Matrix
Tiny square with only one corner finder pattern.
Printed Circuit Boards (PCBs), small electrical components.
  • Capacity Limit: Max ~35 numeric or 21 alphanumeric characters.
  • Scanner Support: Not supported by all smartphone camera apps.
rMQRRectangular Matrix
Long, narrow strip bridging Micro QR and standard QR.
Test tubes, cables, thin bezels, narrow product edges.
  • New Format: Growing support but not universal on legacy scanners.
  • Aspect Ratio: Designed strictly for narrow spaces.

Frequently Asked Questions

What 2D barcode formats can I create in C#?

IronBarcode supports all major 2D barcode formats including QR Code, Aztec, DataMatrix, MaxiCode, PDF417, and the new rMQR format. With support for over 30 barcode formats total, IronBarcode provides a comprehensive solution for generating any 2D barcode type you need in your C# applications.

How do I generate a QR code in just one line of code?

You can create a QR code with a single line using IronBarcode: var myBarcode = BarcodeWriter.CreateBarcode("Hello World", BarcodeEncoding.QRCode); This simple API call generates a fully functional QR code that you can then save as an image or export in various formats.

Do 2D barcodes remain readable if damaged?

Yes, 2D barcodes generated with IronBarcode include built-in error correction that ensures your data remains accessible even when the barcode is torn, scratched, or marked. They can also be scanned from any angle and don't require perfect alignment, making them ideal for challenging scanning conditions.

Which 2D barcode format should I use for mobile ticketing?

For mobile ticketing applications, IronBarcode can generate Aztec Codes which feature a borderless compact design perfect for mobile screens. You can also use QR Codes for general mobile applications, or explore other formats like DataMatrix for industrial uses or PDF417 for ID cards.

How much data can 2D barcodes store compared to traditional barcodes?

While traditional 1D barcodes hold only a few numbers or letters, 2D barcodes created with IronBarcode can store thousands of characters including web links, detailed ID information, and more. The exact capacity depends on the format - PDF417 offers massive offline storage capacity while DataMatrix provides industrial precision for smaller components.

What file formats can I save my generated 2D barcodes in?

IronBarcode allows you to save your 2D barcodes in multiple image formats. You can use SaveAsPng() for PNG files, SaveAsJpeg() for JPEG images, and various other export methods to save your barcodes in the format that best suits your application needs.

Can I generate the new rMQR barcode format?

Yes, IronBarcode supports the new rMQR (Rectangular Micro QR) format along with traditional QR codes and other 2D formats. Simply specify BarcodeEncoding.rMQR when creating your barcode to generate this modern rectangular variant of the QR code.

Is there a free trial available to test 2D barcode generation?

Yes, IronBarcode offers a free trial that allows you to test all 2D barcode generation features before purchasing. You can download the library via NuGet and start creating QR codes, DataMatrix, Aztec codes, and other 2D formats immediately to evaluate if it meets your needs.

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 2,015,591 | Version: 2025.12 just released