
Generate barcode
Draw a 1D or 2D barcode in any of 13 symbologies from bwip-js, on your device.
Generate barcode draws any of 13 symbologies bwip-js supports, from code128 and ean13 through datamatrix and pdf417, from typed text. Scale sets the module width in pixels, 3 by default, and includetext prints the text under the bars where supported. A PNG always sits on opaque white, never transparent, since a real scanner cannot read one that is not.
Questions
Which barcode symbologies can it draw?
Thirteen: code128, code39, code93, ean8, ean13, upca, upce, itf14, gs1-128, datamatrix, pdf417, azteccode and rationalizedCodabar, all rendered by bwip-js. 1D symbologies like code128 and 2D ones like datamatrix and pdf417 are drawn by the same call, with a different bcid.
What does scale control?
The module width in pixels, the width of the narrowest bar or cell. It defaults to 3 and must be a positive number. A larger scale makes a bigger, more scannable image at the cost of file size; the barcode data itself does not change.
Why is the PNG background always solid white?
Because a transparent PNG background reads as unset to a real scanner rather than as white, and testing an EAN-13 rendered transparent found it decoded to zero results even though it looked fine on screen. The PNG output is always drawn on opaque white for that reason; the SVG output has no such restriction.
What happens if my text is not valid for the symbology I picked?
bwip-js refuses and the error names the symbology plus what was wrong, such as a bad length or a bad check digit for a numeric format like ean13. The message it throws is passed through with its internal id prefix stripped off.
Can I get an SVG instead of a PNG?
Yes. format chooses png or svg, png by default. SVG output is vector and has no fixed background colour; PNG output is always rendered on opaque white for scanning reliability.
Does it run on the command line?
Yes. It takes no file input and has no browser-only restriction, so the CLI, MCP and the web page all call the same bwip-js rendering code.
Compare
| Tool | Runs on the CLI | Live as you type |
|---|---|---|
| Generate barcode | Yes | No |
| Generate QR / barcode | Yes | No |
| ISBN to barcode | Yes | No |
| vCard builder | Yes | No |