Generate scannable barcodes in web apps using Syncfusion JavaScript Barcode Generator (linear barcodes, QR Code, Data Matrix). Trigger for barcode rendering, sizing/margins, colors, text display, error correction, quiet zones, encoding options, validation, and exporting to PNG/JPG/PDF for e-commerce, inventory, labels, and document workflows.
When to use this skill: You're building a web application that needs to generate, customize, and export barcodes (linear codes, QR codes, or Data Matrix codes). This includes point-of-sale systems, inventory management, ticketing systems, healthcare applications, or any solution requiring scannable codes.
The Syncfusion Barcode Generator library (@syncfusion/ej2-barcode-generator) provides three main barcode types:
All three use the same core API: initialize with configuration, append to DOM, customize, and export.
📄 Read: references/getting-started.md
📄 Read: references/barcode-types.md
📄 Read: references/qr-code-generation.md
📄 Read: references/data-matrix-codes.md
📄 Read: references/export-printing.md
📄 Read: references/validation-events.md
import { BarcodeGenerator } from '@syncfusion/ej2-barcode-generator';
// Linear barcode (Code128)
const barcode = new BarcodeGenerator({
width: '200px',
height: '150px',
type: 'Code128',
value: 'SYNCFUSION',
mode: 'SVG',
displayText: { visibility: true }
});
barcode.appendTo('#barcode');
// For QR Code
import { QRCodeGenerator } from '@syncfusion/ej2-barcode-generator';
const qrCode = new QRCodeGenerator({
width: '200px',
height: '200px',
value: 'Your value here',
displayText: { visibility: false },
mode: 'SVG'
});
qrCode.appendTo('#qrcode');
// For Data Matrix
import { DataMatrixGenerator } from '@syncfusion/ej2-barcode-generator';
const dataMatrix = new DataMatrixGenerator({
width: '200px',
height: '200px',
value: 'Syncfusion',
mode: 'SVG'
});
dataMatrix.appendTo('#datamatrix');
Pattern 1: Type Selection
Code128 for general-purpose alphanumeric barcodes (most flexible)QRCodeGenerator for URLs, contact info, or when logo branding is neededDataMatrixGenerator for industrial labeling and small-space encodingCode39 for legacy systems or when ASCII is sufficientPattern 2: Customization Pipeline
const barcode = new BarcodeGenerator({
type: 'Code128',
value: data,
width: '200px',
height: '150px',
mode: 'SVG',
foreColor: '#000000',
backgroundColor: '#ffffff',
displayText: { text: label }
});
barcode.appendTo('#element');
Pattern 3: Dynamic Export
// Export to image with filename
barcode.exportImage('mybarcode', 'PNG');
// Export as Base64 for server submission
const base64 = await barcode.exportAsBase64Image('JPG');
Pattern 4: Responsive Sizing
const barcode = new BarcodeGenerator({
width: '100%', // Responsive to container
height: '150px',
type: 'Code128',
value: productCode
});
| Property | Type | Default | Purpose |
|---|---|---|---|
type | string | 'Codabar' | Barcode type (Code39, Code128, etc.) |
value | string | '' | Data to encode in barcode |
width | string | '200px' | Barcode width (px or %) |
height | string | '150px' | Barcode height |
mode | string | 'SVG' | Render mode (SVG or Canvas) |
foreColor | string | '#000000' | Barcode color |
backgroundColor | string | '#ffffff' | Background color |
displayText | object | {} | Display text config (visibility, text, font) |
logo (QR only) | object | null | Logo config (imageSource, width, height) |
errorCorrectionLevel (QR only) | number | 0 | Error correction: 0=Low, 1=Medium, 2=Quarter, 3=High |
Start with Getting Started to set up the library, then select your barcode type using Barcode Types. For customization needs, see Customization & Styling. For export/print workflows, see Export & Printing.