C# QR Code Library

Generate QR Codes with C#

C# developers can use QRCoder, a popular .NET library, to generate QR codes in ASP.NET, WPF, MAUI, and console applications. No external dependencies required.

Installation

Install QRCoder via NuGet Package Manager.

NuGet
dotnet add package QRCoder
Package Manager
Install-Package QRCoder

Generate QR Codes with QRCoder

Code examples using the QRCoder library in C#.

Basic QR Code with QRCoder
using QRCoder;

var qrGenerator = new QRCodeGenerator();
var qrData = qrGenerator.CreateQrCode("https://qrcode.fun",
    QRCodeGenerator.ECCLevel.Q);

// PNG output
var qrCode = new PngByteQRCode(qrData);
byte[] pngBytes = qrCode.GetGraphic(20);
File.WriteAllBytes("qrcode.png", pngBytes);
SVG Output
using QRCoder;

var qrGenerator = new QRCodeGenerator();
var qrData = qrGenerator.CreateQrCode("https://qrcode.fun",
    QRCodeGenerator.ECCLevel.Q);

var svgQrCode = new SvgQRCode(qrData);
string svgString = svgQrCode.GetGraphic(20,
    "#1A2B3C", "#FFFFFF");
File.WriteAllText("qrcode.svg", svgString);
ASP.NET Core Endpoint
app.MapGet("/qr", (string data) =>
{
    var qrGenerator = new QRCodeGenerator();
    var qrData = qrGenerator.CreateQrCode(data,
        QRCodeGenerator.ECCLevel.Q);
    var qrCode = new PngByteQRCode(qrData);
    byte[] png = qrCode.GetGraphic(20);

    return Results.File(png, "image/png");
});
QRCode.fun API

Generate QR Codes via API in C#

Call the QRCode.fun API from C# using HttpClient for styled QR codes.

C# API Integration
using System.Net.Http.Json;

var client = new HttpClient();
var payload = new {
    data = "https://qrcode.fun",
    width = 300,
    height = 300,
    type = "png",
    margin = 10,
    dotsOptions = new { color = "#1A2B3C", type = "rounded" },
    cornersSquareOptions = new { color = "#8564C3", type = "extra-rounded" },
    backgroundOptions = new { color = "#FFFFFF" }
};

var response = await client.PostAsJsonAsync(
    "https://qrcode.fun/api/generate-qr-styled", payload);
var result = await response.Content.ReadFromJsonAsync<JsonElement>();
Console.WriteLine(result.GetProperty("data").GetString()?[..50]);

Live QR Code Preview

Try generating a QR code with C# right now.

QR preview

Native Library vs API

Compare using QRCoder versus the QRCode.fun API.

FeatureQRCoderQRCode.fun API
Setup complexityNuGet installSingle HTTP request via HttpClient
CustomizationColors, logos, shapes (ArtQRCode)Full styling: colors, shapes, logos
Offline supportYesRequires internet
MaintenanceNuGet updateAlways up-to-date
Output formatsPNG, SVG, PDF, ASCIIPNG, SVG

C# QR Code Use Cases

Common scenarios for QR codes in .NET applications.

ASP.NET Web APIs

Generate QR codes in ASP.NET Core APIs for tickets, invoices, authentication tokens, and product pages.

WPF & MAUI Desktop Apps

Create desktop applications with QR code generation for labels, business cards, and asset tracking.

Azure Functions

Deploy QR generation as serverless Azure Functions triggered by HTTP requests or queue messages.

Reporting & PDF

Embed QR codes into PDF reports and documents using QuestPDF or iTextSharp for payment and tracking.

Frequently Asked Questions

Common questions about generating QR codes with C#.

QRCoder is an open-source .NET library for generating QR codes. It supports multiple output formats including PNG, SVG, PDF, and ASCII art, with no external dependencies.

Start generating QR codes with C#

Use our free generator or integrate the API into your .NET applications.