Skip to main content

isbn-pure

Pure-stdlib ISBN-13 and ISBN-10 validator for Python — zero pip dependencies, ≤150 LOC core, ≥100 tests.

from isbn_pure import validate_isbn13, validate_isbn10, normalize_isbn13, normalize_isbn10

validate_isbn13("978-0-13-468599-1")  # -> True
validate_isbn13("978-0-13-468599-0")  # -> False (wrong check digit)
validate_isbn10("0-306-40615-2")       # -> True
validate_isbn10("000000006X")          # -> True (X check digit, verified valid)
normalize_isbn13("978-0-13-468599-1") # -> "9780134685991"
normalize_isbn10("0-306-40615-2")      # -> "0306406152"

Install

pip install -e .

No external dependencies. Python ≥3.8.

Why isbn-pure?

Existing ISBN validators on PyPI require heavy runtime dependencies:

Package Dependencies
pyisbn requests
isbnlib requests, beautifulsoup4, lxml

isbn-pure is zero-dependency — pure stdlib only. Ideal for serverless functions, MicroPython, Pyodide, and any environment where C extensions or network libraries are unavailable.

Key Features

  • ISBN-13 validation — full ISO 2108 checksum validation
  • ISBN-10 validation — full ISBN-10 checksum validation including X check digit (= 10)
  • Normalization — strip hyphens/spaces, returns clean digit string
  • Pure stdlib — zero pip dependencies
  • ≤150 LOC core — auditable, minimal attack surface
  • ≥100 tests — comprehensive valid/invalid/boundary coverage

API Reference

validate_isbn13(isbn: str) -> bool

Returns True if the string is a valid ISBN-13, False otherwise. Strips hyphens and spaces before validation.

validate_isbn10(isbn: str) -> bool

Returns True if the string is a valid ISBN-10, False otherwise. Strips hyphens and spaces. Accepts X (or x) as the check digit in position 10.

normalize_isbn13(isbn: str) -> str

Returns the 13-digit normalized ISBN string if valid, otherwise "".

normalize_isbn10(isbn: str) -> str

Returns the 10-character normalized ISBN string if valid, otherwise "".

compute_check_digit_isbn13(first12: str) -> int

Computes the ISBN-13 check digit (0–9) for a 12-digit prefix.

compute_check_digit_isbn10(first9: str) -> str

Computes the ISBN-10 check digit for a 9-digit prefix. Returns '0'–'9' or 'X'.

Canonical Test Vectors

ISBN-13:

Input Expected Notes
978-0-13-468599-1 Valid Canonical example from ISO 2108 / Wikipedia
978-1-4919-1021-4 Valid Correct check digit (spec had wrong 7)
978-0-306-40615-7 Valid
978-0-13-468599-0 Invalid Wrong check digit
978-0-13-468599- Invalid Truncated

ISBN-10:

Input Expected Notes
0-306-40615-2 Valid CRC Press example from Wikipedia
000000006X Valid Real ISBN-10 with X check digit (verified: total=12, cd=X)
0-306-40615-X Invalid Wrong check digit (correct is 2, not X)
0306406152 Valid Same ISBN without hyphens
123456789X Valid X is valid as check digit (=10)
1234567890 Invalid Wrong check digit

Acceptance Criteria Checklist

  • AC1: validate_isbn13("978-0-13-468599-1") returns True
  • AC2: validate_isbn13("978-0-13-468599-0") returns False
  • AC3: validate_isbn10("0-306-40615-2") returns True
  • AC4: validate_isbn10("155404295X") returns True
  • AC5: normalize_isbn13("978-0-13-468599-1") returns "9780134685991"; invalid returns ""
  • AC6: Normalized ISBN re-validates: validate_isbn13(normalize_isbn13(x)) == True for all valid x
  • AC7: Handles hyphens, spaces, lowercase x accepted for ISBN-10
  • AC8: Pure Python stdlib only — zero pip dependencies
  • AC9: Core LOC ≤ 150 (excluding tests)
  • AC10: 100+ unit tests covering valid/invalid inputs, boundary cases

Run Tests

pip install -e .[dev]
pytest -v

Limitations

Format-only validation. isbn-pure validates the checksum algorithm only — it does NOT query any ISBN registry or database to verify that the ISBN corresponds to an actual published title. A structurally valid ISBN may not correspond to a real book.

Non-Goals

  • ISBN-to-title lookup or registry queries
  • CLI interface
  • ISBN-10 to ISBN-13 conversion ( GS1 conversion)
  • Integration with bibliographic databases

License

MIT

Metadata

Release files for isbn-pure 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 isbn-pure 0.1.0
File Size Uploaded Provenance Actions
isbn_pure-0.1.0.tar.gz 7.8 kB Without provenance Details for isbn_pure-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 12.7 kB

Release files / isbn_pure-0.1.0.tar.gz

Download URL isbn_pure-0.1.0.tar.gz
Size 7.8 kB
Tags Source
SHA-256 checksum
How to use checksums
cb11d099d1da6f4b164ab8c5d850b4218cc5b5c479c63954ccbee3c8bb246c97
BLAKE2b-256 checksum
How to use checksums
e332095cdece99d0d92e5da3a4b69b88dad7d6ec496346132175de68f0260ff1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.15

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

Download URL isbn_pure-0.1.0-py3-none-any.whl
Size 5.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f536705c773ef69b2ab03bdeff0a22e076c2510a1f5d56cd7f51609ae493aa3e
BLAKE2b-256 checksum
How to use checksums
7e18ffaaf79ce22eb65a28b2191ae8727e93b717a18d763f893de684115b5339
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.15

Security for isbn-pure 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