Skip to footer content
USING IRONQR

NuGet QR Code Generator: Generate QR Codes in C# with Just a Few Lines of Code

Generating QR codes in .NET applications has never been more straightforward. With the right NuGet package, developers can create QR codes, customize their appearance, and save them to multiple output formats in just a few lines of code. IronQR delivers enterprise-grade QR code generation with cross-platform support for .NET Core, .NET Framework, and modern .NET versions.

This tutorial demonstrates how to install the IronQR NuGet package and start generating QR codes immediately. Whether building inventory systems, event ticketing platforms, or marketing applications, IronQR provides the tools needed for professional QR code implementation.

Get stated with IronQR now.
green arrow pointer

How Do I Install a QR Code NuGet Package?

Installing IronQR through NuGet Package Manager takes seconds. Open the NuGet Package Manager Console in Visual Studio and run the following command, or use the dotnet add package command for CLI environments:

Install-Package IronQR

The NuGet package automatically handles all dependencies, ensuring compatibility with your target frameworks. IronQR supports .NET Framework 4.6.2+, .NET Core 2.0+, and .NET 5-10, making it a versatile .NET library for any Visual Studio project.

How Can I Generate My First QR Code?

Creating your first NuGet QR code requires minimal source code. The QrWriter class handles QR code and barcodes generation with sensible defaults:

using IronQr;
using IronSoftware.Drawing;
class Program
{
    static void Main(string[] args)
    {
        // Generate a QR code from text data
        QrCode myQr = QrWriter.Write("Hello World");
        // Save QR code as bitmap image
        AnyBitmap qrImage = myQr.Save();
        // Export to PNG file
        qrImage.SaveAs("hello-qr.png");
    }
}
using IronQr;
using IronSoftware.Drawing;
class Program
{
    static void Main(string[] args)
    {
        // Generate a QR code from text data
        QrCode myQr = QrWriter.Write("Hello World");
        // Save QR code as bitmap image
        AnyBitmap qrImage = myQr.Save();
        // Export to PNG file
        qrImage.SaveAs("hello-qr.png");
    }
}
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

QR Code Output

NuGet QR Code Generator: Generate QR Codes in C# with Just a Few Lines of Code: Image 1 - Simple QR output

The QrWriter.Write() method accepts string data and returns a QrCode object containing the QR symbol. The Save() method converts this to an AnyBitmap, which supports encoding to various image formats or even exporting vector data for a XAML Path. This approach works seamlessly across Windows, macOS, and Linux without platform-specific dependencies—unlike libraries relying on System.Drawing that are Windows-only starting with .NET 6.

What Error Correction Levels Are Available?

QR codes support four error correction levels that determine how much damage a code can sustain while remaining scannable. IronQR supports encoding all levels through the QrOptions class:

LevelRecovery CapacityBest For
L (Low)~7%Clean environments, maximum data
M (Medium)~15%General use (default)
Q (Quartile)~25%Industrial applications
H (High)~30%Logos, outdoor signage
using IronQr;
using IronSoftware.Drawing;
class Program
{
    static void Main(string[] args)
    {
        // Configure high error correction level
        var options = new QrOptions(QrErrorCorrectionLevel.High);
        // Generate QR code with options
        QrCode qr = QrWriter.Write("https://ironsoftware.com", options);
        AnyBitmap image = qr.Save();
        image.SaveAs("high-correction-qr.png");
    }
}
using IronQr;
using IronSoftware.Drawing;
class Program
{
    static void Main(string[] args)
    {
        // Configure high error correction level
        var options = new QrOptions(QrErrorCorrectionLevel.High);
        // Generate QR code with options
        QrCode qr = QrWriter.Write("https://ironsoftware.com", options);
        AnyBitmap image = qr.Save();
        image.SaveAs("high-correction-qr.png");
    }
}
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Output

NuGet QR Code Generator: Generate QR Codes in C# with Just a Few Lines of Code: Image 2 - QR with high correction level

Higher error correction levels create denser QR symbols with more raw modules, enabling the code to remain readable even when partially obscured or damaged.

How Do I Customize QR Code Appearance?

IronQR provides extensive styling options through QrStyleOptions, enabling custom colors, dimensions (set as an int), margins, and logo embedding:

using IronQr;
using IronSoftware.Drawing;
class Program
{
    static void Main(string[] args)
    {
        // Create styled QR code with custom colors
        var styleOptions = new QrStyleOptions
        {
            Dimensions = 300,
            Margins = 10,
            Color = Color.DarkBlue,
            BackgroundColor = Color.White
        };
        QrCode qr = QrWriter.Write("https://example.com");
        AnyBitmap styledImage = qr.Save(styleOptions);
        styledImage.SaveAs("styled-qr.png");
    }
}
using IronQr;
using IronSoftware.Drawing;
class Program
{
    static void Main(string[] args)
    {
        // Create styled QR code with custom colors
        var styleOptions = new QrStyleOptions
        {
            Dimensions = 300,
            Margins = 10,
            Color = Color.DarkBlue,
            BackgroundColor = Color.White
        };
        QrCode qr = QrWriter.Write("https://example.com");
        AnyBitmap styledImage = qr.Save(styleOptions);
        styledImage.SaveAs("styled-qr.png");
    }
}
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Styled QR Output

NuGet QR Code Generator: Generate QR Codes in C# with Just a Few Lines of Code: Image 3 - Styled QR Code

Adding logos to QR codes enhances brand recognition. The styling system automatically positions logos while maintaining scannability—a significant advantage over open source library alternatives that require manual calculations.

How Do I Save QR Codes to Different Output Formats?

IronQR supports multiple output formats including PNG, JPEG, GIF, TIFF, BMP, and SVG. The SaveAs method automatically detects the format from the file extension:

using IronQr;
using IronSoftware.Drawing;
class Program
{
    static void Main(string[] args)
    {
        QrCode qr = QrWriter.Write("Format demo");
        AnyBitmap image = qr.Save();
        // Save to different PNG file formats
        image.SaveAs("qr-output.png");
        image.SaveAs("qr-output.jpg");
        image.SaveAs("qr-output.gif");
        // Get as byte array for streams
        byte[] pngBytes = image.ExportBytes();
    }
}
using IronQr;
using IronSoftware.Drawing;
class Program
{
    static void Main(string[] args)
    {
        QrCode qr = QrWriter.Write("Format demo");
        AnyBitmap image = qr.Save();
        // Save to different PNG file formats
        image.SaveAs("qr-output.png");
        image.SaveAs("qr-output.jpg");
        image.SaveAs("qr-output.gif");
        // Get as byte array for streams
        byte[] pngBytes = image.ExportBytes();
    }
}
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Multiple QR Code Output Formats

NuGet QR Code Generator: Generate QR Codes in C# with Just a Few Lines of Code: Image 4 - QR codes saved as different file formats

For embedding QR codes in PDF documents, IronQR provides the StampToExistingPdfPage method, enabling direct QR code placement on existing documents without additional libraries.

How Does IronQR Compare to QRCoder?

The QRCoder library is a popular open-source library for QR code generation. However, developers who previously had to run install package qrcoder often found the multi-step process involving qrcodeimage qrcode.getgraphic calls cumbersome. Unlike some community libraries that may have been last updated months ago, IronQR offers several advantages for enterprise development:

FeatureIronQRQRCoder
Cross-PlatformFull .NET Core/5+ supportWindows-only for bitmap rendering
ML-Powered Reading99.9% accuracy detectionGeneration only
PDF IntegrationNative stamping supportRequires additional libraries
Commercial Support24/5 engineering supportCommunity only

While the package QRCoder works well for basic generation, IronQR's machine learning model provides superior QR code reading from any angle, critical for applications processing user-submitted images. The new QRCodeGenerator approach in IronQR (QrWriter) requires fewer lines of code than QRCoder's multi-step process involving QRCodeGenerator, QRCodeData, and QRCode rendering classes.

How Can I Encode Binary Data?

Beyond text, IronQR supports encoding byte arrays for binary QR code data:

using IronQr;
using IronSoftware.Drawing;
class Program
{
    static void Main(string[] args)
    {
        // Encode binary data
        byte[] binaryData = System.Text.Encoding.UTF8.GetBytes("Binary content");
        QrCode qr = QrWriter.Write(binaryData);
        qr.Save().SaveAs("binary-qr.png");
    }
}
using IronQr;
using IronSoftware.Drawing;
class Program
{
    static void Main(string[] args)
    {
        // Encode binary data
        byte[] binaryData = System.Text.Encoding.UTF8.GetBytes("Binary content");
        QrCode qr = QrWriter.Write(binaryData);
        qr.Save().SaveAs("binary-qr.png");
    }
}
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Output

NuGet QR Code Generator: Generate QR Codes in C# with Just a Few Lines of Code: Image 5 - Binary encoded QR code

This capability enables encoding encrypted payloads, serialized objects, or any binary content within QR symbols.

Conclusion

IronQR transforms QR code generation from a complex task into a straightforward integration. With NuGet installation, cross-platform compatibility, and features to embed codes in PDFs and ML-powered reading, it provides all the core features needed for professional .NET applications.

The library's intuitive API means developers can generate QR codes, apply custom styling, and export to multiple formats without wrestling with platform limitations or sparse documentation.

Get started with a free trial to explore the full feature set, or purchase a license for production deployment with commercial support.

Frequently Asked Questions

How can I generate QR codes in C# using IronQR?

You can generate QR codes in C# by installing the IronQR NuGet package. It allows you to create and customize QR codes with just a few lines of code.

What platforms does IronQR support?

IronQR offers cross-platform support, compatible with .NET Core, .NET Framework, and modern .NET versions.

Can I customize the appearance of QR codes using IronQR?

Yes, IronQR allows you to customize the appearance of QR codes, including colors and design, to match your specific needs.

What output formats are supported for saving QR codes?

With IronQR, you can save QR codes in multiple output formats, making it versatile for various applications.

Does IronQR support PDF embedding for QR codes?

Yes, IronQR supports embedding QR codes into PDF documents, enhancing document accessibility and functionality.

How easy is it to implement IronQR in a .NET application?

Implementing IronQR in a .NET application is straightforward. By installing the NuGet package, you can start generating QR codes with minimal code.

Is IronQR suitable for enterprise-grade QR code generation?

IronQR is designed for enterprise-grade QR code generation, providing robust and reliable performance across various platforms.

Does IronQR offer any advanced features for QR code reading?

IronQR includes ML-powered reading capabilities, ensuring accurate and efficient QR code scanning and processing.

Jordi Bardia
Software Engineer
Jordi is most proficient in Python, C# and C++, when he isn’t leveraging his skills at Iron Software; he’s game programming. Sharing responsibilities for product testing, product development and research, Jordi adds immense value to continual product improvement. The varied experience keeps him challenged and engaged, and he ...
Read More