Saving QR Codes as SVG in IronQR
IronQR does not export QR codes directly to SVG. You can still produce a vector file by redrawing the generated bitmap as SVG rectangles with a third-party library.
The reason is the underlying image stack. IronQR uses SixLabors.ImageSharp for image processing, which handles raster formats such as PNG, JPEG, and BMP but offers no SVG output. SVG simply is not a target format the dependency supports.
Solution
Generate the QR code with IronQR as usual, then walk its pixels and rebuild the matrix as vector shapes using Svg.NET. You keep IronQR's QR generation and gain full control over the SVG's styling and structure.
1. Generate the QR Code and Convert to a Bitmap
Write the QR code, save it to an AnyBitmap, then cast that to a System.Drawing.Bitmap so the pixels can be read individually.
var qr = QrWriter.Write("Hello SVG");
var anyBitmap = qr.Save();
// Convert AnyBitmap to System.Drawing.Bitmap
System.Drawing.Bitmap bit = anyBitmap;
2. Redraw the Pixels as SVG Rectangles
Create an SvgDocument sized to the bitmap, then loop the pixels and add a 1x1 SvgRectangle wherever a pixel reads as black. The threshold check (R, G, and B all below 128) treats near-black pixels as filled cells.
// Create new SVG document
var svgDoc = new SvgDocument
{
Width = bit.Width,
Height = bit.Height
};
// Loop through bitmap pixels and add black pixels as SVG rectangles
for (int y = 0; y < bit.Height; y++)
{
for (int x = 0; x < bit.Width; x++)
{
System.Drawing.Color pixel = bit.GetPixel(x, y);
// Check if pixel is black (or close enough)
if (pixel.R < 128 && pixel.G < 128 && pixel.B < 128)
{
var rect = new SvgRectangle
{
X = x,
Y = y,
Width = 1,
Height = 1,
Fill = new SvgColourServer(System.Drawing.Color.Black)
};
svgDoc.Children.Add(rect);
}
}
}
3. Write the SVG File
Save the document to disk once every black cell has been added.
// Save the result as SVG
svgDoc.Write("qr-from-ironqr.svg");
This gives you a scalable, vector-based QR code suitable for print or high-resolution use.

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.