IronBarcode How-Tos .NET Create Barcodes as HTML How to Export Barcodes as HTML Hairil Hasyimi Bin Omar Updated:June 22, 2025 An output from a good API must be versatile enough for users to use it further in their program or application, and not necessarily be saved on the disk. That is why IronBarcode offers many options for users to export the GeneratedBarcode into various types, and one of them is exporting the barcodes generated as HTML. Speaking of exporting the GeneratedBarcode into HTML as either a Data URL, HTML Tag, or HTML File, in this article, we'll discuss how we can export to each format. How to Export Barcodes as HTML in C# Download C# library to export barcodes Export barcodes as Data URL Export barcodes as HTML tag Export barcodes as HTML file Get started with IronBarcode Start using IronBarcode in your project today with a free trial. First Step: Start for Free Export Barcode as Data URL Before discussing how to export a barcode as a Data URL, we need to first know what exactly is a data URL. Data URL, also known as Data URI, is a type of Uniform Resource Identifier (URI) that allows data to be embedded directly in the URL string, inline in web pages as if they were external resources. This can be in any format, which includes text, images, audio, video, and binary data. The obtained Data URL can later be used in HTML inside an image tag as a src attribute. Here's a code snippet demonstrating how we can convert our GeneratedBarcode into a Data URL. :path=/static-assets/barcode/content-code-examples/how-to/ExportBarcodeAsDataUrl.cs using IronBarCode; using System; GeneratedBarcode myBarcode = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode/", BarcodeEncoding.QRCode); var dataUrl = myBarcode.ToDataUrl(); Console.WriteLine(dataUrl); Imports IronBarCode Imports System Private myBarcode As GeneratedBarcode = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode/", BarcodeEncoding.QRCode) Private dataUrl = myBarcode.ToDataUrl() Console.WriteLine(dataUrl) $vbLabelText $csharpLabel From the code snippet above, we started off with creating a barcode using the CreateBarcode() method from the BarcodeWriter class with the barcode value and the barcode encoding as the arguments for this method. In order to get the Data URL of the barcode, we attached the ToDataUrl() method to the GeneratedBarcode. Export Barcode as HTML Tag Another way to export our GeneratedBarcode to HTML is by exporting it into an HTML tag using the ToHtmlTag() method. This method renders the GeneratedBarcode object as a fully formed HTML tag that can be injected directly into HTML without having to reference it in any JavaScript, CSS, or image dependencies. The following code snippet demonstrates how to export as an HTML tag. :path=/static-assets/barcode/content-code-examples/how-to/ExportBarcodeAsHtmlTag.cs using IronBarCode; using System; GeneratedBarcode myBarcode = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode/", BarcodeEncoding.QRCode); var htmlTag = myBarcode.ToHtmlTag(); Console.WriteLine(htmlTag); Imports IronBarCode Imports System Private myBarcode As GeneratedBarcode = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode/", BarcodeEncoding.QRCode) Private htmlTag = myBarcode.ToHtmlTag() Console.WriteLine(htmlTag) $vbLabelText $csharpLabel From the code snippet above, we can simply attach the ToHtmlTag() method to the GeneratedBarcode in order to obtain the HTML tag of the barcode generated. This HTML tag can directly be embedded into a larger HTML file. Export Barcode as HTML File Users can also opt to save the GeneratedBarcode as an HTML file instead. To do this, use the SaveAsHtmlFile() method. The following code snippet demonstrates how to use this method. :path=/static-assets/barcode/content-code-examples/how-to/ExportBarcodeAsHtmlFile.cs using IronBarCode; GeneratedBarcode myBarcode = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode/", BarcodeEncoding.QRCode); myBarcode.SaveAsHtmlFile("myBarcode.html"); Imports IronBarCode Private myBarcode As GeneratedBarcode = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode/", BarcodeEncoding.QRCode) myBarcode.SaveAsHtmlFile("myBarcode.html") $vbLabelText $csharpLabel This method accepts a string of a file path. Looking into the HTML file generated, we can see the barcode outputted as an HTML tag within the <html>, <head>, and <body> tags that make up a complete HTML file. Frequently Asked Questions What is a Data URL? A Data URL, also known as Data URI, is a type of Uniform Resource Identifier (URI) that allows data to be embedded directly in the URL string, inline in web pages as if they were external resources. This can include text, images, audio, video, and binary data. How can I export a barcode as a Data URL? To export a barcode as a Data URL, you can use the ToDataUrl() method on a GeneratedBarcode object from IronBarcode. This converts the barcode into a Data URL, which can then be used directly in an HTML image src attribute. What method is used to export a barcode as an HTML tag? To export a barcode as an HTML tag, you can use the ToHtmlTag() method provided by IronBarcode. This method renders the GeneratedBarcode object as a fully formed HTML tag. How do I save a generated barcode as an HTML file? You can save a generated barcode as an HTML file using the SaveAsHtmlFile() method from IronBarcode. You'll need to specify a file path where the HTML file will be saved, and the method will create the file with the barcode embedded as an HTML tag. What are the steps to export barcodes as HTML in C#? The steps to export barcodes as HTML in C# include downloading the IronBarcode library, creating a barcode with BarcodeWriter, and then using methods like ToDataUrl(), ToHtmlTag(), or SaveAsHtmlFile() to export the barcode in the desired HTML format. Can the library export barcodes in formats other than HTML? Yes, IronBarcode offers a variety of options to export barcodes in different formats, not just HTML. This flexibility allows developers to use the generated barcodes in multiple ways within their applications. Is it necessary to save the barcode images to disk? No, it is not necessary to save the barcode images to disk. IronBarcode provides options to export barcodes in formats that can be used directly in applications without saving them to disk, such as Data URLs or HTML tags. What is the advantage of using this library for barcode generation in .NET? IronBarcode is a powerful .NET library that simplifies the process of barcode generation and export. It provides versatile methods to export barcodes in various formats, which can be easily integrated into .NET applications. Hairil Hasyimi Bin Omar Chat with engineering team now Software Engineer Like all great engineers, Hairil is an avid learner. He’s refining his knowledge of C#, Python, and Java, using that knowledge to add value to team members across Iron Software. Hairil joined the Iron Software team from Universiti Teknologi MARA in Malaysia, where he graduated with a Bachelor's degree in Chemical and Process Engineering. Ready to Get Started? Free NuGet Download Total downloads: 1,743,856 View Licenses