Skip to main content

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

Metadata

Release files for larzphone 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 larzphone 0.1.0
File Size Uploaded Provenance
larzphone-0.1.0.tar.gz 5.8 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 11.5 kB

Release files / larzphone-0.1.0.tar.gz

Download URL larzphone-0.1.0.tar.gz
Size 5.8 kB
Tags Source
SHA-256 checksum
How to use checksums
05573a3ff183301e16f31141d7f039c187f1cb005654a0146368e42e7b666f75
BLAKE2b-256 checksum
How to use checksums
8c224bf37207e695b883d6af9bded935207a75be5493bd4bedff1249459f7207
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

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

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

Security for larzphone 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