Generate deterministic, GitHub-style identicons from any input string (e.g., username or user ID), with an option to generate random identicons. Identicons (“identity icons”) are simple visuals derived from an identifier so users get a consistent avatar without uploading an image.
- 🎯 Deterministic identicons from any string (username, user ID, email, etc.).
- Not globally unique, but the same input always yields the same identicon — like a hash function.
- 🎲 Random identicons for placeholders or testing.
- ⚡ Built with FastAPI for speed and easy integration.
This system can be treated like a non-cryptographic hash:
- It is deterministic: same input → same identicon.
- It is not cryptographically secure and not guaranteed unique across all inputs.
- Visual pattern bits: 15 bits
- Color bits (RGB): 8 × 3 = 24 bits
- Total entropy: 15 + 24 = 39 bits
- With 39 bits of entropy, the total design space is 2³⁹ = 549,755,813,888 distinct identicons.
ℹ️ While 2³⁹ possibilities is large for UI purposes, this is far less than typical cryptographic hashes (e.g., 256 bits). Do not use identicons as security identifiers or for collision-sensitive logic.
- Take the input string (e.g.,
user_id
). - Derive a stable seed from it (e.g., a hash).
- Map parts of that seed to:
- Grid/shape decisions (15 bits)
- Color (RGB) (24 bits total)
- Render the corresponding SVG/PNG.
GET /identicon?string=<string>&size=<px>
→ deterministic identicon for<string>
.GET /identicon/avatar?size=<px>
→ random identicon.
- Default avatars for apps and dashboards
- Placeholder images for seeded test data
- Visual differentiation without user uploads
- Deterministic behavior ensures a consistent avatar for each identifier (similar to GitHub).
- Not suitable for cryptographic, authentication, or collision-intolerant applications.