A simple timezone lookup by zip code
Maintained. Last release 7 months ago.
pip install zip2tzzip2tz
Fast, zero-dependency US zip code to timezone lookup for Python.
- 38,000+ zip codes mapped to IANA timezones
- Zero dependencies — pure Python, works everywhere
- O(1) lookup — instant hash table lookups, no database or file I/O
- Tiny footprint — ~100KB installed, loads in milliseconds
- Type-annotated — full type hints included
Installation
pip install zip2tz
Or with uv:
uv add zip2tz
Usage
import zip2tz
# Get timezone for a zip code
tz = zip2tz.timezone("90210")
print(tz) # America/Los_Angeles
tz = zip2tz.timezone("10001")
print(tz) # America/New_York
# Works with integers too
tz = zip2tz.timezone(60601)
print(tz) # America/Chicago
# Returns None if zip code not found
tz = zip2tz.timezone("00000")
print(tz) # None
Why zip2tz?
Most timezone lookup libraries require external databases, network calls, or heavy dependencies. zip2tz bakes the data directly into Python bytecode — just import and go.
| Feature | zip2tz | Other libraries |
|---|---|---|
| Dependencies | 0 | Often requires pytz, databases, or APIs |
| Lookup speed | O(1) hash | Varies (file I/O, network, etc.) |
| Install size | ~100KB | Often MB+ |
| Offline | Yes | Sometimes requires network |
API
timezone(zipcode: str | int) -> str | None
Returns the IANA timezone string (e.g., "America/New_York") for the given US zip code, or None if not found.
Parameters:
zipcode— A 5-digit US zip code as a string or integer
Returns:
- IANA timezone string, or
Noneif the zip code is not in the database
Coverage
Covers all 50 US states plus DC, including: