Barcode Generator
Generate CODE128, EAN, UPC, CODE39, ITF, and other 1D barcodes as SVG or PNG
Most common general-purpose barcode. Any ASCII characters.
How to Barcode Generator Online
Generate a scannable 1D barcode (CODE128, EAN, UPC, CODE39, ITF, etc.) entirely in your browser. Export as SVG or PNG.
- Pick a format. CODE128 is the safe default for general use; EAN-13 or UPC-A for retail products.
- Enter the value. Each format has its own character / length rules — the example loaded with each format shows the right shape.
- Adjust appearance: bar width (1–6 px), height, colors, toggle the value below the barcode.
- Copy the SVG markup for inline embedding, or download SVG/PNG. The PNG export renders at 2× resolution for crisp print.
About Barcode Generator
Barcodes are a 70-year-old technology that still works because the alternatives keep being worse for specific use cases. RFID tags are great but cost cents per unit and need a reader; QR codes are great but read poorly from far away and don't fit on a narrow product label edge; printed text is human-readable but slow to scan. The 1D barcode keeps winning the narrow-label, fast-scan, cheap-to-produce niche because the physical format is hard to beat: a few millimeters of black and white that any laser or camera scanner reads in milliseconds.
This tool generates those barcodes in your browser. Drop a value, pick a format, get a scalable SVG (or rasterized PNG) you can print on a label, embed in a document, or display on a screen. Eight formats are supported, covering nearly every realistic use case:
- **CODE128** — the modern general-purpose format. ASCII characters of any length, decent density, every scanner reads it. The right default for anything that isn't a retail product. - **EAN-13** — global retail standard. 12 input digits, the encoder adds the 13th check digit. Used everywhere outside the US for retail scanning. - **EAN-8** — compact retail variant. 7 input digits + check digit. Used on small products where there's not enough label space for full EAN-13. - **UPC-A** — US retail standard. 11 input digits + check digit. Used on US-sold consumer products. - **CODE39** — industrial / asset-tag format. Alphanumeric (A–Z, 0–9, and a handful of symbols). Older than CODE128 but more tolerant of low-resolution printing, which is why it persists in industrial settings. - **ITF-14** — shipping carton format. 13 input digits + check digit. Used on outer cartons (the wholesale-pack barcode, not the individual-product one). - **Codabar** — niche format with start/stop characters. Common in libraries, blood banks, and FedEx tracking labels. - **MSI Plessey** — numeric-only format. Used in inventory and warehouse systems where a custom check-digit calculation is required.
The implementation uses **JsBarcode**, the standard JavaScript barcode library. It's been the de-facto choice for in-browser 1D barcode generation since 2014 and is what most React/Vue/Angular barcode component libraries wrap underneath. The library is small (~30 KB after gzip) and renders directly to SVG, which gives you crisp scaling at any size.
The tool exposes the controls that actually matter: format, value, bar width, height, colors, and whether to display the value text below the bars. Less-common JsBarcode options (font size, font face, text margin, ean-13 quiet zone customization) are not exposed because their defaults are correct for 99% of use cases. If you need them, the SVG-copy option gives you raw markup you can edit in any text editor.
**Bar width** is the most important printability setting. The default (2 px on screen) translates to roughly 0.5 mm at 100% print scale, which scans reliably on every modern scanner. Cranking it up to 4–6 px produces a chunkier barcode that prints well on low-resolution thermal printers (the kind that produce shipping labels and grocery price tags). Going below 2 px is fine for high-resolution screens but risky for print — the narrowest bars blur to gray.
**Height** is largely cosmetic for scanning. The barcode's information is encoded in the horizontal pattern of bars and spaces; the vertical height is just so a hand-held scanner has room to point. Anything from 30 to 100 pixels works fine. Tall barcodes look more "industrial"; short ones save vertical label space.
**Color** can be customized but you should keep dark bars on a light background (the standard "high contrast" requirement of barcode scanning). Inverted (white bars on dark background) does not scan reliably — most scanners assume dark-on-light. Custom colors (e.g., navy bars on cream) work as long as the contrast ratio is high enough.
**The PNG export renders at 2× the on-screen size**. This is the right tradeoff for print: small enough to keep file sizes manageable but high enough to look sharp at the displayed dimensions. If you need higher resolution (poster-size barcodes), use the SVG export and let the print pipeline rasterize at the appropriate DPI.
**Show value text below the bars** is on by default. This is the human-readable backup in case the barcode itself is unreadable for any reason (scratched label, fading print, scanner failure). Most production barcodes include it. Toggle off only when label space is tight or when the value is meant to be opaque to humans (system-internal IDs).
**Edge cases handled:** invalid value for the chosen format produces a clear error message rather than a broken render; the format's expected character set / length is documented under the value field; the example loaded with each format demonstrates the right shape; SVG and PNG outputs both work in every modern browser; URL.createObjectURL lifecycle is properly cleaned up on every download.
**Privacy.** Everything happens in your browser. JsBarcode is a JS library that runs locally. The value you encode never goes to a server. Open DevTools and watch the Network panel during generation — empty. This matters for barcodes that encode sensitive data (internal product SKUs, customer order numbers, anything you'd rather not see indexed by a third-party logging system).
Related Tools
Frequently Asked Questions
Which barcode format should I use?
**CODE128** is the safe default for general-purpose use. It encodes any ASCII characters, has decent density, and every barcode scanner reads it. Use **EAN-13** or **UPC-A** only if you're labeling retail products that will be scanned at a point of sale (these are the global standards for that). Use **CODE39** if you specifically need a format that's easy to print on low-resolution industrial equipment. Use **ITF-14** for shipping cartons. The rest (Codabar, MSI) are niche; pick them only if a specific downstream system requires them.
Why is my EAN-13 / UPC failing with 'invalid'?
Both formats require an exact digit count. EAN-13 needs exactly 12 digits (the 13th is a check digit added automatically). UPC-A needs exactly 11 digits (the 12th is the check digit). If you paste 13 digits assuming the last one is the check digit, the encoder rejects it because it computes its own check digit and yours doesn't match. Drop the last digit and let the encoder add the right check digit.
What's a 'check digit' and why does it matter?
A check digit is a single digit computed from the other digits using a formula. It catches the most common human errors when reading or typing a barcode — single-digit substitution, adjacent-digit transposition. Every retail barcode format includes one. The generator computes it for you; you don't type it.
Should I export SVG or PNG?
**SVG for digital use** (websites, PDFs, anything that gets viewed on screen). Vector graphics scale to any size without artifacts and remain crisp on retina displays. **PNG for print** if your print workflow doesn't accept SVG (some label printers don't). Our PNG export renders at 2× the on-screen size so it prints sharply at the displayed dimensions.
How small can I print a barcode and still have it scan?
The 'X-dimension' (width of the narrowest bar) is the limiting factor. Most retail scanners can read barcodes with X-dim down to about 0.25 mm; thermal label printers can usually produce that. For inkjet or laser printing, stay above 0.33 mm X-dim to avoid bleed and ink-spread issues. Print at 100% scale; downscaling a barcode in software produces unscannable output because anti-aliasing blurs the bar edges.
Can I make a 2D barcode like QR or Data Matrix?
Not in this tool — JsBarcode handles 1D barcodes only. For QR codes, use the <a href="/tools/qr-code-generator">QR Code Generator</a>. Data Matrix and PDF417 aren't currently supported; if you need those, a dedicated library like bwip-js is the right tool (heavier but more formats).
Is the barcode uploaded anywhere?
No. JsBarcode is a JavaScript library that renders the barcode entirely in your browser. The encoded value, the rendered SVG, and the PNG output never leave your tab. Verify in DevTools — generate any barcode and watch the network panel stay empty.