Skip to content

Menu

Barcode Generator

Generate Code128 barcodes as SVG

Runs entirely in your browserGeneratorsFree, no sign-up
Loading tool

01What is Barcode Generator?

Need a scannable label for a bin, an asset tag or a test fixture? Type the value and this tool draws it as a Code 128 barcode in SVG. Vector output means the bars stay sharp at any print size. Code 128 is defined in the ISO/IEC 15417 standard. It has three code sets. This tool uses code set B only, which covers ASCII 32 to 127. That includes upper and lower case letters, digits, the space and common punctuation. Each character takes one symbol. The encoding follows the spec step by step. It starts with the Start B symbol, value 104. Each character maps to its char code minus 32, so A is 33. The check symbol is a weighted sum: the start value, plus each character value times its position, taken mod 103. Last comes the stop pattern. Every symbol is six alternating bar and space widths, from one to four modules wide. The stop pattern has seven elements. Each bar is drawn as a black rect on a white background. The text sits centered under the bars in a 12 px monospace font. Here is the smallest case. Encoding just A gives Start B, then A, then a check value of 34, since 104 plus 33 is 137 and 137 mod 103 is 34. Then the stop. That is 46 modules in total. With a bar width of 1 and a quiet zone of 10, the SVG comes out 66 pixels wide. You control Bar Width (the narrow module in pixels), Height and Quiet Zone. The quiet zone is blank space added on both sides. The defaults are 2, 80 and 20. Now the limits. Any character outside ASCII 32 to 127, such as é or an emoji, shows a warning and no barcode is drawn. Because only set B is used, the tool never switches to set C. Set C packs two digits per symbol, so long numeric strings come out wider here than an optimizing encoder would make them. It also does not add GS1-128 application identifiers, so it is not for shipping labels that need them. The barcode is built in the page itself. The text you encode is not uploaded, and Download SVG saves a file straight from your browser.

Developers testing scanner input and small teams printing internal labels who need a quick Code 128 barcode as a clean SVG. The tool runs entirely in your browser, so your data never leaves your device.

02How to use Barcode Generator

  1. Type your value into Text to Encode (ASCII 32-127), or start from an example such as Product SKU or Serial Number.
  2. Set Bar Width (px), Height (px) and Quiet Zone (px) to fit your label.
  3. Check the preview. If you see the invalid characters warning, remove accented letters or symbols outside plain ASCII.
  4. Click Copy SVG Code to paste the markup into a template, or Download SVG to save a file.
  5. Open View SVG Source if you want to read or tweak the generated markup.

03Worked examples

Input: A (Bar Width 1, Height 40, Quiet Zone 10)
Result: <svg ... width="66" height="60" viewBox="0 0 66 60"> <rect width="66" height="60" fill="white"/> <rect x="10" y="0" width="2" height="40" fill="black"/> ... 12 more bars ... <text x="33" y="55" ...>A</text> </svg>
Trimmed. 46 modules plus 10 px quiet zone on each side gives 66 px. The SVG height is the bar height plus 20 px for the text.
Input: A
Result: Start B 211214, A 111323, check 34 131123, stop 2331112
Bar and space widths for each symbol. The check value is (104 + 33 x 1) mod 103 = 34.
Input: Hi
Result: Start B 211214, H 231113, i 142112, check 124112, stop 2331112
H is value 40 and i is value 73. The check is (104 + 40 + 146) mod 103 = 84.
Input: SKU-12345-AB (defaults: Bar Width 2, Height 80, Quiet Zone 20)
Result: <svg ... width="374" height="100" viewBox="0 0 374 100"> with 46 black bars
Trimmed. Twelve characters plus start, check and stop make 15 symbols and 167 modules, so 334 px of bars plus 40 px of quiet zone.
Input: café
Result: Warning: Invalid characters detected. Code128B supports ASCII 32-127 only.
The é is outside code set B, so no barcode is drawn until you remove it.

04Common use cases

  • Printing bin location or SKU labels for a small stockroom where a USB scanner reads them into a spreadsheet
  • Making asset tags for laptops and monitors so an inventory sheet can be filled by scanning
  • Creating known-good barcodes to test a point-of-sale or warehouse scanning app during development
  • Dropping a vector barcode into a packing slip or label template that gets resized for different printers
  • Encoding sample IDs on lab tubes or serial numbers on event wristbands
  • Checking what Code 128 bar pattern and check symbol a given string should produce when debugging your own encoder

05Tips

  • Keep the quiet zone at least ten times the bar width. The Code 128 spec asks for 10 modules of blank space on each side, and scanners fail when bars touch other artwork.
  • The downloaded file is named barcode- plus your text with every non-alphanumeric character turned into an underscore, so SKU-12345-AB saves as barcode-SKU_12345_AB.svg.
  • Scale the whole SVG up rather than setting Bar Width to 1 for print. Single-pixel modules can blur or drop out on low-resolution label printers.
  • For retail products sold through shops, scanners at checkout expect a registered EAN or UPC code, not Code 128.

06Related concepts

Code 128, code set B, mod 103 checksum, quiet zone, SVG.

Frequently Asked Questions

What is Barcode Generator?

Barcode Generator is a free, browser-based developer tool on AIDToolStack. Generate Code128 barcodes as SVG It requires no installation or sign-up and works entirely in your browser.

Is Barcode Generator free to use?

Yes. No sign-up, no fees and no usage cap.

Does Barcode Generator store my data?

No. It runs in your browser; nothing is uploaded.

Reviews and commentsShow

Reviews

Sign in to leave a review.

Loading reviews…

Comments

Sign in to leave a comment.

Loading comments…

What changed in AI dev tools, once a month

Renames, shutdowns, pricing changes and new MCP setups, each with a source.

Subscribe