How to Implement Custom QR Code Colors
QR codes have evolved from simple black-and-white patterns into powerful branding tools. In 2025, businesses recognize that a well-designed QR code can reinforce brand identity while maintaining full scannability. Customizing the foreground and background colors of your QR codes allows you to create visually appealing designs that stand out.
IronQR makes it simple to modify QR code colors using the QrStyleOptions class. You can change the foreground color (the dark modules), the background color, or both to match your brand guidelines.
In this how-to guide, we'll walk through different ways to customize QR code colors using IronQR in C#.
Quickstart: Customize QR Code Colors
Set foreground and background colors through QrStyleOptions and save the styled QR code.
-
Install IronQR with NuGet Package Manager
PM > Install-Package IronQR -
Copy and run this code snippet.
var qrCode = QrWriter.Write("https://example.com"); var style = new QrStyleOptions { Color = Color.DarkBlue, BackgroundColor = Color.LightYellow }; qrCode.Save(style).SaveAs("colored-qr.png"); -
Deploy to test on your live environment
Start using IronQR in your project today with a free trial
Minimal Workflow (5 steps)
- Download the C# library to create QR codes with custom colors
- Create a QR code using the
QrWriterclass - Initialize
QrStyleOptionsto configure appearance - Set the
ColorandBackgroundColorproperties - Save the styled QR code using
SaveAs
Change Background Color
The background color of a QR code is the lighter area surrounding the dark modules. By default, this is white, but you can change it to any color that provides sufficient contrast with the foreground.
Setting a custom background color is useful when placing QR codes on colored surfaces or when you want to match your brand's color palette. Just ensure there's enough contrast for scanners to read the code reliably.
:path=/static-assets/qr/content-code-examples/how-to/implement-custom-qr-code-background.cs
using IronQr;
using IronSoftware.Drawing;
// Create a QR code
QrCode qr = QrWriter.Write("https://ironsoftware.com/csharp/qr/");
// Set background color
QrStyleOptions styleOptions = new QrStyleOptions()
{
BackgroundColor = Color.LightBlue
};
// Save QR code with custom background
AnyBitmap qrImage = qr.Save(styleOptions);
qrImage.SaveAs("qrBackgroundColor.png");
Imports IronQr
Imports IronSoftware.Drawing
' Create a QR code
Dim qr As QrCode = QrWriter.Write("https://ironsoftware.com/csharp/qr/")
' Set background color
Dim styleOptions As New QrStyleOptions() With {
.BackgroundColor = Color.LightBlue
}
' Save QR code with custom background
Dim qrImage As AnyBitmap = qr.Save(styleOptions)
qrImage.SaveAs("qrBackgroundColor.png")
Change Foreground Color
The foreground color represents the dark modules of the QR code—the actual data pattern that scanners read. While black is the standard choice, you can use any darker color that maintains good contrast against your background.
Changing the foreground color lets you incorporate your brand's primary color into the QR code design. Deep blues, dark greens, or rich burgundies work well as alternatives to black.
:path=/static-assets/qr/content-code-examples/how-to/implement-custom-qr-code-foreground.cs
using IronQr;
using IronSoftware.Drawing;
// Create a QR code
QrCode qr = QrWriter.Write("https://ironsoftware.com/csharp/qr/");
// Set background color
QrStyleOptions styleOptions = new QrStyleOptions()
{
Color = Color.PaleVioletRed
};
// Save QR code with custom background
AnyBitmap qrImage = qr.Save(styleOptions);
qrImage.SaveAs("qrBackgroundColor.png");
Imports IronQr
Imports IronSoftware.Drawing
' Create a QR code
Dim qr As QrCode = QrWriter.Write("https://ironsoftware.com/csharp/qr/")
' Set background color
Dim styleOptions As New QrStyleOptions() With {
.Color = Color.PaleVioletRed
}
' Save QR code with custom background
Dim qrImage As AnyBitmap = qr.Save(styleOptions)
qrImage.SaveAs("qrBackgroundColor.png")
Conclusion
Customizing QR code colors with IronQR opens up creative possibilities while keeping your codes fully functional:
- Background Color: Use
BackgroundColorto change the lighter area behind the QR pattern - Foreground Color: Use
Colorto modify the dark modules that encode your data - Combined Styling: Set both properties together for complete brand alignment
Remember to maintain adequate contrast between foreground and background colors to ensure reliable scanning across different devices and lighting conditions.
For more styling options including logos, margins, and dimensions, visit the IronQR documentation or explore additional code examples on GitHub.

