Skip to main content

larzbarcode

EAN-13 and Code 128 barcodes as SVG — zero dependencies.

Encode retail EAN-13 product codes and general-purpose Code 128 (ASCII) into a module bitmap and a crisp SVG, with correct check digits and the standard patterns. No image library. Pairs naturally with larzqr when you need 2D codes too.

Install

pip install larzbarcode

Use

from larzbarcode import ean13, code128, ean13_check_digit

ean13("400638133393").to_svg("product.svg")   # 12 digits -> check digit appended
ean13("4006381333931")                         # or pass 13 (verified)
code128("SHIP-42").to_svg("label.svg")

ean13_check_digit("978014300723")              # 4
ean13("4006381333931").modules                 # the 0/1 bar pattern (95 modules)

Why it's correct

  • EAN-13 check digits are verified against known real codes, and the output is the fixed 95-module structure with correct guard bars (101 … 01010 … 101).
  • Code 128 uses the standard 107-pattern table (validated internally — every pattern's bar/space widths sum to 11, the stop to 13) with the weighted mod-103 checksum.

Tests

python -m unittest discover -s tests -v   # 16 tests

The Larz stack

One of 60+ pure-Python, zero-dependency libraries at github.com/larz-scripter. The 1D companion to larzqr (QR codes).

License

MIT (c) larz-scripter

Metadata

Release files for larzbarcode 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for larzbarcode 0.1.0
File Size Uploaded Provenance
larzbarcode-0.1.0.tar.gz 6.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for larzbarcode 0.1.0
File Interpreter ABI Platform
larzbarcode-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 12.5 kB

Release files / larzbarcode-0.1.0.tar.gz

Download URL larzbarcode-0.1.0.tar.gz
Size 6.5 kB
Tags Source
SHA-256 checksum
How to use checksums
b00d5ee32e947d419f216f7b7fc0f8155dbf6fbf174e66409b145d238c5f5785
BLAKE2b-256 checksum
How to use checksums
aa8b8d56ec2c44da87f35bf24ca5d373dd1151ad380236f84d92504843115f7e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / larzbarcode-0.1.0-py3-none-any.whl

Download URL larzbarcode-0.1.0-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
51870b257aff58d0a0d207e4f3fe94cb52dc94d7515e21dfaaf3107a9b03da1e
BLAKE2b-256 checksum
How to use checksums
ec078ad71f9a6113eeccd868d46d0aaae489d334aa91532a9b1f48620c4452a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Security for larzbarcode 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page