Barcodes, made open.
Open Barcode for Python
Barcode module patterns for Python: UPC-A, EAN-13 and Code 39. The package has no runtime dependencies and supports Python 3.9 and later.
Open Barcode is available in several languages:
- Java: https://github.com/openbarcode/java
- C#: https://github.com/openbarcode/csharp
- Python: https://github.com/openbarcode/python
- PHP: https://github.com/openbarcode/php
- JavaScript: https://github.com/openbarcode/javascript
Project homepage: https://openbarcode.dev
Installation
python -m pip install openbarcode
Usage
Each class takes the code as a string and returns its module pattern from barcode(): a list of 1 (bar) and 0 (space) values. Rendering the pattern as an image or SVG is up to your application.
from openbarcode.linear import UPC, EAN, Code39
upc = UPC("03600029145") # 11 digits: the check digit is calculated
upc.code # "036000291452"
len(upc.barcode()) # 95
UPC("036000291452") # 12 digits: the check digit is verified
EAN("400638133393") # 12 digits: the check digit is calculated
Code39("hello world").code # "HELLO WORLD": input is uppercased
Supported inputs:
UPC: UPC-A, 11 or 12 digits.EAN: EAN-13, 12 or 13 digits.Code39: 0-9, A-Z, space, and-.$/+%.
Invalid input raises ValueError. This covers a wrong length, non-digits in UPC or EAN, a check digit that does not match, and characters Code 39 does not support. A non-string argument raises TypeError.
Testing
The tests use the standard library unittest module. From a clone of this repository:
python -m pip install .
python -m unittest discover -s tests -t .
To run against the source tree without installing, set PYTHONPATH=src:
PYTHONPATH=src python -m unittest discover -s tests -t .
The continuous integration workflow in .github/workflows/ci.yml runs the same tests on Python 3.10 through 3.13.
This repository was split from the original multi-language project at https://github.com/floms/Open-Barcode. The commit history was preserved with git-filter-repo; commit hashes differ from the original.
Copyright 2013 Floms, LLC (Yoel Nunez)
Copyright 2026 Floms, Inc.
Licensed under the Apache License, Version 2.0. See LICENSE.md for details.
Metadata
Release files for openbarcode 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| openbarcode-2.0.0.tar.gz | 13.2 kB | With provenance | Details for openbarcode-2.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| openbarcode-2.0.0-py3-none-any.whl | Python 3 | none | any | Details for openbarcode-2.0.0-py3-none-any.whl |
Total release size: 26.5 kB
Release files / openbarcode-2.0.0.tar.gz
| Download URL | openbarcode-2.0.0.tar.gz |
|---|---|
| Size | 13.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
df09c3aa4f0e8d80848f1a6636dd527a9e30acc01fdf9d9468cc656e12a884fb
|
|
BLAKE2b-256 checksum How to use checksums |
509aff100c05a05ff7f8d4edbe682bb19730bd325706ed4e23842370399875ce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.
Transparency logRelease files / openbarcode-2.0.0-py3-none-any.whl
| Download URL | openbarcode-2.0.0-py3-none-any.whl |
|---|---|
| Size | 13.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8f1bc4dcdf09d363e1d4c948cca5fcbcc7f8e01d4b1a8f2df35f65b3daa61fc6
|
|
BLAKE2b-256 checksum How to use checksums |
6b164bf9a072f1ff974ab6e82e14f9590f2559f21691e183e753c93ecbcd6966
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.
Transparency logSecurity for openbarcode 2.0.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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for openbarcode-2.0.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.
Transparency logA 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.