Barcode Generator

Generate barcodes in CODE128, EAN-13, UPC-A, CODE39, ITF-14 and more.

10 FORMATS PNG + SVG BATCH MODE NO UPLOAD

Live Preview

CODE128 0 chars
Enter a value to generate your barcode
Ready SVG format — crisp at any size

Batch Mode

Barcode Value

CODE128 accepts most ASCII characters.

Barcode Format

Appearance

Preset palettes
2
100
18

Quick Actions

100% Private

Barcodes are generated locally in your browser. Nothing is uploaded.

10 Barcode Formats

CODE128, EAN-13, UPC-A, CODE39, ITF-14, MSI, Pharmacode, Codabar, EAN-8 and UPC-E.

Batch Mode

Generate dozens of barcodes at once from a list of values — perfect for labels.

PNG & SVG Export

Download high-quality PNG for print or SVG for design tools like Illustrator and Figma.

What is the Barcode Generator?

The ToolBajar Barcode Generator is a free, browser-based tool for creating 1D barcodes in ten popular formats — including CODE128, EAN-13, UPC-A, CODE39, ITF-14, MSI, Pharmacode, Codabar, EAN-8 and UPC-E. Enter a value, choose a format, customise colours and size, then download the result as a PNG or SVG. You can also generate dozens of barcodes at once using Batch Mode. Everything runs locally in your browser — no uploads, no accounts, no tracking.

Complete Guide to Barcode Formats

How to use this tool

  1. Enter a Value

    Type the text or number you want to encode. CODE128 accepts nearly any character; EAN/UPC formats require specific digit counts.

  2. Choose a Format

    Pick from CODE128, EAN-13, UPC-A, CODE39, ITF-14 and more. The live preview updates instantly.

  3. Customise Appearance

    Adjust bar colour, background, width, height, font size and whether to show the value below the bars.

  4. Download or Batch

    Download as PNG or SVG, or switch to Batch Mode to generate dozens of barcodes at once from a list of values.

Who should use this tool?

Small Businesses

Create product barcodes and inventory labels without paying for commercial software.

Warehouse & Logistics

Generate ITF-14 shipping labels and MSI inventory tags in bulk.

Event Organizers

Print unique ticket barcodes for events, conferences and raffles.

Everyday Users

Create quick barcodes for personal projects, crafts, or simple labeling tasks.

Frequently Asked Questions

Yes — completely free, with no sign-up, no watermark and no limit on how many barcodes you generate.

No. Everything is generated locally in your browser with JavaScript. Nothing you type is sent to a server.

For global retail, use EAN-13. For US and Canada, use UPC-A. Both encode product codes and are universally supported by retail scanners.

EAN-13 needs exactly 13 digits, UPC-A needs exactly 12, EAN-8 needs 8, and ITF-14 needs 14. If the digit count is wrong, the barcode can't be generated. Check the format hint under the value input for requirements.

PNG is a raster image — great for screens, but it becomes blurry when scaled up. SVG is a vector format that stays crisp at any size, so it's better for printing and for editing in tools like Illustrator or Figma.

Yes. Enable Batch Mode and enter one value per line. All barcodes will be generated with your current format and appearance settings — ready for individual or bulk download.

`); w.document.close(); setTimeout(() => { w.focus(); w.print(); }, 200); } /* ---------------- BATCH ---------------- */ function generateBatch() { const raw = $batchInput.value.trim(); if (!raw) { Swal.fire('Nothing to generate', 'Enter at least one value.', 'info'); return; } const lines = raw.split(/\r?\n/).map(l => l.trim()).filter(l => l.length); if (!lines.length) { Swal.fire('Nothing to generate', 'Enter at least one value.', 'info'); return; } // Limit for safety const limited = lines.slice(0, 100); $batchResults.innerHTML = ''; let okCount = 0; let firstOkSvg = null; limited.forEach((line, idx) => { const valid = validateValue(line, state.format); const row = document.createElement('div'); row.className = 'workspace-card'; row.style.padding = '1rem'; row.style.background = 'rgba(191,172,200,.10)'; const head = document.createElement('div'); head.style.display = 'flex'; head.style.justifyContent = 'space-between'; head.style.alignItems = 'center'; head.style.gap = '.5rem'; head.style.marginBottom = '.5rem'; head.style.fontSize = '.75rem'; head.style.fontWeight = '800'; head.style.color = '#783F8E'; head.innerHTML = `#${idx + 1} · ${escapeHtml(line)}`; row.appendChild(head); if (!valid.ok) { const msg = document.createElement('div'); msg.style.fontSize = '.78rem'; msg.style.color = '#dc2626'; msg.style.fontWeight = '700'; msg.textContent = valid.msg; row.appendChild(msg); } else { const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); svg.style.maxWidth = '100%'; svg.style.height = 'auto'; svg.style.display = 'block'; row.appendChild(svg); const ok = renderBarcode(svg, line, state.format, state); if (ok) { okCount++; if (!firstOkSvg) firstOkSvg = svg; } } // actions const actions = document.createElement('div'); actions.style.display = 'flex'; actions.style.flexWrap = 'wrap'; actions.style.gap = '.4rem'; actions.style.marginTop = '.5rem'; if (valid.ok) { const dlPng = document.createElement('button'); dlPng.className = 'batch-btn'; dlPng.innerHTML = ' PNG'; dlPng.onclick = () => { const svg = row.querySelector('svg'); svgToPngBlob(svg, function (blob) { if (!blob) return; downloadBlob(blob, 'barcode-' + line.replace(/[^a-z0-9_-]/gi, '_').slice(0, 40) + '.png'); }); }; actions.appendChild(dlPng); const dlSvg = document.createElement('button'); dlSvg.className = 'batch-btn'; dlSvg.innerHTML = ' SVG'; dlSvg.onclick = () => { const svg = row.querySelector('svg'); const svgString = new XMLSerializer().serializeToString(svg); const blob = new Blob([svgString], { type: 'image/svg+xml;charset=utf-8' }); downloadBlob(blob, 'barcode-' + line.replace(/[^a-z0-9_-]/gi, '_').slice(0, 40) + '.svg'); }; actions.appendChild(dlSvg); } row.appendChild(actions); $batchResults.appendChild(row); }); if (okCount > 0) { $downloadBatchBtn.disabled = false; toast(okCount + ' barcode(s) generated!'); } else { $downloadBatchBtn.disabled = true; } } function downloadBatchAll() { const rows = $batchResults.querySelectorAll('.workspace-card'); if (!rows.length) { toast('Nothing to download', 'info'); return; } const items = []; rows.forEach((row, i) => { const svg = row.querySelector('svg'); if (!svg) return; const svgString = new XMLSerializer().serializeToString(svg); const valueLabel = row.querySelector('span').textContent; items.push({ svg: svgString, label: valueLabel }); }); if (!items.length) { toast('Nothing to download', 'info'); return; } // Download each SVG individually (browser allows multiple downloads) let idx = 0; function next() { if (idx >= items.length) { toast('All downloaded!'); return; } const it = items[idx]; const safe = it.label.replace(/[^a-z0-9_-]/gi, '_').slice(0, 40); const blob = new Blob([it.svg], { type: 'image/svg+xml;charset=utf-8' }); downloadBlob(blob, 'barcode-' + (idx + 1) + '-' + safe + '.svg'); idx++; setTimeout(next, 300); } next(); } /* ---------------- EVENT WIRING ---------------- */ $value.addEventListener('input', function () { state.value = this.value; updatePreview(); }); document.querySelectorAll('[data-sample]').forEach(btn => { btn.addEventListener('click', function () { $value.value = btn.getAttribute('data-sample'); state.value = $value.value; updatePreview(); }); }); $randomValueBtn.addEventListener('click', function () { const n = Math.floor(Math.random() * 1e12).toString().padStart(12, '0'); $value.value = n; state.value = n; updatePreview(); }); $formatGrid.addEventListener('click', function (e) { const btn = e.target.closest('[data-format]'); if (!btn) return; state.format = btn.getAttribute('data-format'); renderFormatGrid(); // Suggest a valid value for the format if (state.format === 'EAN13' && !/^\d{13}$/.test($value.value)) { $value.value = '5901234123457'; } else if (state.format === 'EAN8' && !/^\d{8}$/.test($value.value)) { $value.value = '96385074'; } else if (state.format === 'UPC' && !/^\d{12}$/.test($value.value)) { $value.value = '123456789012'; } else if (state.format === 'UPCE' && !/^\d{6,8}$/.test($value.value)) { $value.value = '123456'; } else if (state.format === 'ITF14' && !/^\d{14}$/.test($value.value)) { $value.value = '12345678901231'; } else if ((state.format === 'MSI' || state.format === 'pharmacode') && !/^\d+$/.test($value.value)) { $value.value = '1234567'; } state.value = $value.value; updatePreview(); }); $barColor.addEventListener('input', function () { state.barColor = this.value; renderPaletteGrid(); updatePreview(); }); $bgColor.addEventListener('input', function () { state.bgColor = this.value; renderPaletteGrid(); updatePreview(); }); $paletteGrid.addEventListener('click', function (e) { const btn = e.target.closest('[data-palette]'); if (!btn) return; const p = PALETTES[parseInt(btn.getAttribute('data-palette'), 10)]; if (!p) return; state.barColor = p.bar; state.bgColor = p.bg; $barColor.value = p.bar; if (p.bg !== 'transparent') $bgColor.value = p.bg; renderPaletteGrid(); updatePreview(); }); $barWidth.addEventListener('input', function () { state.barWidth = parseFloat(this.value); $barWidthVal.textContent = this.value; updatePreview(); }); $barHeight.addEventListener('input', function () { state.barHeight = parseInt(this.value, 10); $barHeightVal.textContent = this.value; updatePreview(); }); $fontSize.addEventListener('input', function () { state.fontSize = parseInt(this.value, 10); $fontSizeVal.textContent = this.value; updatePreview(); }); $toggleText.addEventListener('click', function () { state.showText = !state.showText; this.classList.toggle('active', state.showText); updatePreview(); }); $toggleMargin.addEventListener('click', function () { state.quietZones = !state.quietZones; this.classList.toggle('active', state.quietZones); updatePreview(); }); $downloadPngBtn.addEventListener('click', downloadPng); $downloadSvgBtn.addEventListener('click', downloadSvg); $copySvgBtn.addEventListener('click', copySvg); $printBtn.addEventListener('click', printBarcode); $regenerateBtn.addEventListener('click', function () { updatePreview(); toast('Barcode regenerated!'); }); $resetAllBtn.addEventListener('click', function () { state.value = '123456789012'; state.format = 'CODE128'; state.barColor = '#000000'; state.bgColor = '#ffffff'; state.barWidth = 2; state.barHeight = 100; state.fontSize = 18; state.showText = true; state.quietZones = true; $value.value = state.value; $barColor.value = state.barColor; $bgColor.value = state.bgColor; $barWidth.value = state.barWidth; $barWidthVal.textContent = state.barWidth; $barHeight.value = state.barHeight; $barHeightVal.textContent = state.barHeight; $fontSize.value = state.fontSize; $fontSizeVal.textContent = state.fontSize; $toggleText.classList.add('active'); $toggleMargin.classList.add('active'); renderFormatGrid(); renderPaletteGrid(); updatePreview(); toast('Reset to defaults', 'info'); }); /* Batch toggle */ $toggleBatch.addEventListener('click', function () { state.batch = !state.batch; if (state.batch) { $batchPanel.classList.remove('hidden'); this.innerHTML = ' Disable'; } else { $batchPanel.classList.add('hidden'); this.innerHTML = ' Enable'; } }); $generateBatchBtn.addEventListener('click', generateBatch); $downloadBatchBtn.addEventListener('click', downloadBatchAll); $clearBatchBtn.addEventListener('click', function () { $batchInput.value = ''; $batchResults.innerHTML = ''; $downloadBatchBtn.disabled = true; toast('Batch cleared', 'info'); }); /* ---------------- INIT ---------------- */ function init() { renderFormatGrid(); renderPaletteGrid(); updatePreview(); // Ensure fonts load before first render if (document.fonts && document.fonts.ready) { document.fonts.ready.then(updatePreview); } } init(); })();