base36
raw JSON → 0.1.1 verified Mon Apr 27 auth: no python
A Python library for encoding and decoding integers to/from base36 strings. Version 0.1.1 is the latest stable release as of April 2026. The library is actively maintained with no breaking changes reported.
pip install base36 Common errors
error TypeError: 'str' object cannot be interpreted as an integer ↓
cause Passing a string to encode instead of an integer.
fix
Convert the string to int first: encode(int('123'))
error ValueError: invalid literal for int() with base 36: '...' ↓
cause Decode expects a valid base36 string; non-alphanumeric characters cause this error.
fix
Ensure the input string contains only 0-9 and a-z (or A-Z) characters.
Warnings
gotcha Input type: encode expects an integer, decode expects a string. Passing incorrect types will raise TypeError. ↓
fix Ensure encode receives an int and decode receives a str.
gotcha Case sensitivity: decode is case-insensitive but returns an integer. Lowercase output from encode is standard. ↓
fix Use lowercase strings for consistency; decode handles uppercase as well.
Imports
- encode
from base36 import encode - decode
from base36 import decode
Quickstart
from base36 import encode, decode
# Encode integer to base36 string
encoded = encode(123456789)
print(encoded) # Output: '21i3v9'
# Decode base36 string back to integer
decoded = decode('21i3v9')
print(decoded) # Output: 123456789