Tools Guides
developer Free No signup

Barcode Generator

Generate barcodes in Code 128, Code 39, EAN-13, UPC-A, and ITF-14 formats and download as SVG or PNG.

Loading tool…

About this tool

Create standard barcodes instantly in your browser with no server required. Supports Code 128, Code 39, EAN-13, UPC-A, and ITF-14 formats with pure-JS encoding and SVG rendering. The tool calculates check digits automatically and lets you download the result as a vector SVG or a raster PNG.

How to use

  1. 1 Select the barcode format from the dropdown (e.g. Code 128, EAN-13).
  2. 2 Type the value you want to encode in the input field.
  3. 3 The barcode renders instantly as an SVG image below the form.
  4. 4 Click 'Download SVG' or 'Download PNG' to save the barcode file.

How a 1D barcode encodes data in bars and spaces

A linear (one-dimensional) barcode stores information in the widths of alternating black bars and white spaces along a single line. A scanner sweeps a beam across the symbol, measures how long it stays dark versus light, and translates that sequence of widths back into characters. Each symbology — Code 128, Code 39, EAN-13, UPC-A, ITF-14 — is just a different rulebook for which width patterns map to which characters, plus rules for the start, stop, and check structures that let a scanner know where the code begins, ends, and whether it read correctly. This tool implements those rulebooks in pure JavaScript and draws the result as a crisp SVG, so the bars stay sharp at any size.

Choosing the right symbology

FormatAcceptsTypical use
Code 128All printable ASCIIShipping labels, internal tracking, anything alphanumeric
Code 39A–Z, 0–9, space, - . $ / + %Industry, military, ID badges (older, less dense)
EAN-1312 or 13 digitsRetail products sold internationally
UPC-A11 or 12 digitsRetail products in North America
ITF-1413 or 14 digitsShipping cartons and cases of retail goods

If you just need to encode an arbitrary string — a serial number, a URL fragment, a product name — Code 128 is the right default: it is compact and handles the full ASCII set. The numeric retail formats only exist to fit the global product-numbering system and reject any non-digit input.

The check digit: a worked example

Retail barcodes append a check digit that lets a scanner detect a misread. For EAN-13 it is computed from the first 12 digits: multiply each digit by 1 or 3 in alternating positions, sum them, and the check digit is whatever makes that sum a multiple of 10. Take 400638133393. Summing digits in odd positions (1st, 3rd, …) times 1 and even positions times 3 gives a weighted total; the check digit is (10 − (total mod 10)) mod 10. This tool does that automatically — if you enter 12 digits it calculates and appends the 13th for you, and if you enter all 13 it validates the last one and refuses the code if it doesn't match. That validation is a feature: a typo in a product number produces a barcode that real scanners would reject anyway, so the tool catches it up front. UPC-A is computed the same way (it is internally an EAN-13 with a leading zero), and ITF-14 uses an equivalent modulo-10 scheme.

Practical tips for codes that actually scan

  • Keep the quiet zone. Barcodes need clear white margin on both ends (roughly 10× a narrow-bar width for EAN/UPC). The SVG includes padding — don't crop it away when placing the code.
  • Download SVG for print, PNG for the web. SVG is vector, so it stays razor-sharp at any print size; the PNG export rasterizes at 2× resolution for places that won't accept SVG. For physical labels, prefer SVG.
  • Don't stretch the height freely, and never the width. Horizontal scaling distorts the bar-to-space ratios the scanner relies on. Resize proportionally only.
  • Mind contrast. Black bars on a white background is the safe choice. Red bars or low-contrast colors can be invisible to laser scanners, which often read in red light.
  • Test on the real medium. Print it and scan it with a phone or handheld reader before committing to a run; ink bleed and glossy glare both reduce readability.

Common mistakes

  • Wrong digit count. EAN-13 needs exactly 12 or 13 digits, UPC-A 11 or 12, ITF-14 13 or 14. Spaces and dashes are stripped, but letters in a numeric format are rejected.
  • Expecting Code 39 to handle lowercase. Standard Code 39 is uppercase only; this tool uppercases your input automatically, which can surprise you if case mattered.
  • Confusing a 1D barcode with a QR code. These linear codes hold a short identifier, not a webpage. For URLs and rich data, use a QR (2D) code instead.

Everything runs in your browser

All encoding, check-digit calculation, and rendering happen entirely on your device in JavaScript. Nothing you type is sent to a server, so product numbers and serial codes you generate stay private — you can confirm this by generating a barcode with your network disconnected.

Frequently Asked Questions

{# Alpine.js — self-hosted. (The previous jsdelivr CDN tag had a stale SRI integrity hash, so the browser refused to run it and window.Alpine was never defined — silently breaking every FAQ accordion and Alpine tool.) #}