A compact, SkiaSharp-based .NET library for generating common 1D barcodes. Focused on reliability, correctness and a small API surface so it's easy to use from services and agent workflows.
Example:
using var barcode = new Barcode(opt => opt.Type = BarcodeTypes.Ean13);
string validated = barcode.Encode("123456789012");
barcode.Export("barcode.png");👉 Complete Documentation - Comprehensive guides, API reference, and examples
- Getting Started Guide - Generate your first barcode in minutes
- API Reference - Complete class and method documentation
- Code Examples - Common usage patterns and scenarios
- Advanced Topics - Custom fonts, validation, and optimization
10 industry-standard formats for every use case:
| Type | Use Case | Example |
|---|---|---|
| EAN-13 | 🛒 Retail products, European standard | 1234567890128 |
| UPC-A | 🇺🇸 North American retail, grocery | 012345678905 |
| UPC-E | 📦 Compact retail, small packages | 01234565 |
| ISBN-13 | 📚 Books and publications | 9781234567897 |
| EAN-8 | 📦 Small packages, compact spaces | 12345670 |
| CODE-39 | 🏭 Industrial, automotive, defense | ABC-123 |
| CODE-93 | 📋 Logistics, inventory management | ABC123 |
| CODE-128 | 📊 High-density alphanumeric encoding | ABC123xyz |
| CODABAR | 🏥 Libraries, blood banks, logistics | A123456A |
| ITF | 📦 Distribution, warehousing, cartons | 12345678 |
- Compact, easy-to-use API (fluent configuration)
- Built-in validation helpers (see
BarcodeValidator) - Export templating: use placeholders like
{barcode},{format}in file names - Cross-platform rendering using SkiaSharp
Choose your preferred installation method:
Package Manager Console:
Install-Package TyKonKet.BarcodeGeneratorCLI Command:
dotnet add package TyKonKet.BarcodeGeneratorGet up and running in 30 seconds:
dotnet add package TyKonKet.BarcodeGeneratorusing SkiaSharp;
using TyKonKet.BarcodeGenerator;
// Simple barcode generation
using var barcode = new Barcode(options => {
options.Type = BarcodeTypes.Ean13;
options.Height = 50;
options.Scaling = 3;
});
string validatedCode = barcode.Encode("123456789012");
barcode.Export("my-barcode.png");// Advanced styling with custom colors and fonts
using var styledBarcode = new Barcode(options => {
options.Type = BarcodeTypes.Ean13;
options.ForegroundColor = SKColors.DarkBlue;
options.TextColor = SKColors.Red; // 🆕 Independent text color!
options.BackgroundColor = SKColors.LightGray;
options.UseTypeface("Arial", SKFontStyle.Bold);
options.Margins = 10;
});
string result = styledBarcode.Encode("123456789012");
styledBarcode.Export("styled-barcode.png", SKEncodedImageFormat.Png, 100);// Dynamic file naming with placeholders
barcode.Export("output/{barcode}_{quality}.{format}", SKEncodedImageFormat.Png, 95);
// Creates: output/1234567890128_95.png// NEW: Validate barcode data without encoding
var result = BarcodeValidator.Validate("123456789012", BarcodeTypes.Ean13);
if (result.IsValid)
{
Console.WriteLine($"✓ Valid: {result.ValidatedBarcode}");
// Output: ✓ Valid: 1234567890128 (with check digit)
}
else
{
Console.WriteLine($"✗ Errors: {string.Join(", ", result.Errors)}");
// Get suggestions for compatible barcode types (opt-in)
var resultWithSuggestions = BarcodeValidator.Validate("ABC123", BarcodeTypes.Ean13, includeSuggestions: true);
if (resultWithSuggestions.SuggestedTypes.Count > 0)
{
Console.WriteLine($"💡 Try: {string.Join(", ", resultWithSuggestions.SuggestedTypes)}");
}
}💡 Need more help? Check out our Getting Started Guide for step-by-step tutorials and examples.
📚 Validation API: See the complete Validation API Documentation for detailed usage.
- E-commerce product barcodes (EAN/UPC)
- Inventory and asset tracking
- Library ISBN generation
- Label printing and batch export
The BarcodeOptions class provides extensive customization capabilities:
| Option | Description | Default |
|---|---|---|
| Type | Barcode encoding type (EAN-13, UPC-A, ISBN-13, EAN-8, CODE-93, CODE-128) | EAN-8 |
| Height | Height of barcode bars | 30 pixels |
| Scaling | Scale factor for the entire image | 5x |
| Margins | Spacing around the barcode | 2 pixels |
| Colors | Background, foreground, and text colors (independent control) | White/Black |
| Text Rendering | Show/hide text below barcode | Enabled |
| Font Options | Custom fonts, styles, and loading methods | System default |
📚 Detailed Configuration: See our BarcodeOptions API Reference for complete documentation.
BarcodeGenerator supports multiple .NET framework versions for maximum compatibility:
| Framework | Version | Target Scenario |
|---|---|---|
| .NET Standard 2.0 | 2.0+ | Core compatibility for most scenarios |
| .NET Framework | 4.6.2+ | Legacy Windows applications |
| .NET 8.0 | 8.0+ | Long-term support version |
| .NET 10.0 | 10.0+ | Latest stable version |
- PolySharp Integration: The library now includes the
PolySharppackage to enhance compatibility. If you encounter any issues, please report them by opening an issue on our GitHub repository. For more details, visit the PolySharp GitHub repository. - API Rename:
EncodesExtensionshas been renamed toBarcodeTypeExtensionsto better reflect its purpose. Update consuming code accordingly. - Framework requirement: .NET 6 support has been dropped in favor of the current
net8.0/net10.0targets; make sure callers move to those runtimes.
- Framework Requirement: No longer supports .NET Standard 1.3 (requires .NET Standard 2.0+).
- API Changes: Redesigned for improved usability and customization.
- SkiaSharp Update: Updated to SkiaSharp 3.116.1 for better performance.
📖 Migration Guide: See our Getting Started documentation for updated API usage patterns.
- CODE-39, CODE-128, CODABAR, ITF and UPC-E
- Validation API: standalone validation without encoding (
BarcodeValidator) - PolySharp integration to improve compatibility across target frameworks
- Independent text color support (
BarcodeOptions.TextColor) and rendering improvements
Have an idea? Start a discussion or vote on features!
We welcome contributions from the community! 🎉
👉 Full Contributing Guide - Complete guide to contributing with setup, workflows, and guidelines
Quick Start:
- 🐛 Found a bug? Report it here
- ✨ Have an idea? Start a discussion
- 🚀 Ready to code? Check out good first issues
Essential Checks:
- Run tests:
dotnet test --configuration Release - Check coverage:
./tools/run-coverage.sh - Follow our Code of Conduct
Every contribution matters - from typo fixes to new features! ✨
This library is released under the MIT License. See the LICENSE file for details.
📚 Explore Full Documentation | 🚀 Getting Started Guide | 🔧 API Reference