larzphone
Parse, validate and format phone numbers to E.164 — offline, zero dependencies.
A practical, libphonenumber-style helper without the multi-megabyte metadata or any dependency. Parse a messy number into its country and national parts, validate its length, and format it as E.164, international or national — all from a compact built-in table covering the major calling regions.
Install
pip install larzphone
Use
from larzphone import parse, is_valid, format_e164
n = parse("+1 (415) 555-2671")
n.region, n.country_code, n.national_number # 'US', '1', '4155552671'
n.e164() # '+14155552671' (store this)
n.international() # '+1 415 555 2671'
parse("0803 123 4567", region="NG").e164() # '+2348031234567'
is_valid("+44 20 7946 0958") # True
is_valid("+1415555") # False (too short for US)
E.164 is the one format you should persist — parse(...).e164() normalizes any
input (spaces, dashes, parens, 00/+ prefixes) to it.
Tests
python -m unittest discover -s tests -v # 19 tests
The Larz stack
One of 60+ pure-Python, zero-dependency libraries at github.com/larz-scripter. Handy alongside larzvalidate for form input.
License
MIT (c) larz-scripter
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file larzphone-0.1.0.tar.gz.
File metadata
- Download URL: larzphone-0.1.0.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
05573a3ff183301e16f31141d7f039c187f1cb005654a0146368e42e7b666f75
|
|
| MD5 |
a0afba7ae5915189987d3123d194f0fd
|
|
| BLAKE2b-256 |
8c224bf37207e695b883d6af9bded935207a75be5493bd4bedff1249459f7207
|
File details
Details for the file larzphone-0.1.0-py3-none-any.whl.
File metadata
- Download URL: larzphone-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cb700033a957c68a411ea176982a17753082b48a1789d98d1b8f7961c186f475
|
|
| MD5 |
c69850b9d6c3e383ef8cc766e0864d5b
|
|
| BLAKE2b-256 |
fb59bad3b251153e40201097b5673aa832a10c73fa8e9822682483e7ea0ba1c1
|