Profile Colors
NIP-XX
Profile Colors
draft optional ui
A standard for deriving deterministic, readable colors from Nostr pubkeys. This ensures consistent visual identity across all clients.
Abstract
Nostr apps often use random colors for default avatars, profile names, and chat bubbles. This NIP proposes deriving a unique, consistent color from each user's pubkey instead — one that is readable in both light and dark modes, and avoids grays.
Motivation
Currently, clients generate profile colors inconsistently. Different algorithms produce different colors for the same pubkey, fragmenting the user experience.
Standardizing pubkey-derived colors:
- Ensures consistent identity across all clients
- Provides predictable, reproducible colors
- Works as text, background, border, or indicator dot without extra UI elements
Color Derivation
Algorithm
- Convert the 64-character hex pubkey to an integer
- Calculate the Hue:
integer % 360 - Set Saturation to
70% - Set Value/Brightness based on Hue range:
| Hue Range | Brightness |
|---|---|
| 32–204 | 75% |
| 216–273 | 96% |
| Otherwise | 90% |
- Convert HSV to the desired format (RGB, Hex, HSL, etc.)
Text Readability
When using the profile color for text (author names, mentions, etc.), adjust brightness:
- Dark mode: increase brightness by
+8% - Light mode: decrease brightness by
-5%
This ensures readable text in both modes without runtime luminance calculations.
Example
Given pubkey a1b2c3d4e5f6...:
- Convert to integer:
461184877... - Hue:
461184877 % 360 = 197 - Saturation:
70% - Hue 197 is in range 32–204 → Brightness:
75% - HSV(197, 70%, 75%) → RGB
Client Behavior
Clients SHOULD:
- Use the derived color for default avatars, profile names, and indicators when no profile picture is available
- Apply text brightness adjustments for the current theme (light/dark)
- Support the color as background, text, border, or dot indicator
Clients MAY:
- Use the color as a placeholder while loading a profile picture
- Use the color as fallback if the profile picture URL fails to load