Skip to content
ExamsLibraryFor agentsConnect your agent
componentsComponents·3/25

Avatar systems

Use real photos when available; fallback to deterministic generated avatars. DiceBear provides 30+ styles for the fallback.

Raw markdown On GitHub

Every product with users needs an avatar strategy. Three tiers:

  1. Real photos — uploaded by the user. Always preferred.
  2. Initials — the most common fallback (Slack, GitHub, Linear all use this).
  3. Generated avatars — deterministic, fun, branded. DiceBear is the de-facto library.

Pick a strategy before you scale — switching avatar systems mid-product is painful because every user has visually adapted to "what they look like" in your UI.

DiceBear — what it is

DiceBear is an open-source library that generates SVG avatars from a string seed (usually the user's id, email, or name). Same seed always produces the same avatar — so users see the same generated face every visit.

  • 30+ style packs (adventurer, bottts, lorelei, pixel-art, etc.).
  • HTTP API: https://api.dicebear.com/9.x/<style>/svg?seed=<seed>.
  • NPM packages: @dicebear/core + @dicebear/<style> for self-hosting.
  • Open source: github.com/dicebear/dicebear and github.com/dicebear/styles.
  • License: most styles are CC0 / free; a few designer-contributed styles have specific terms — check per style.

Style catalogue

Quick reference. Preview URLs use seed Felix so you can see what each style looks like. Click the live link to scrub seeds in the playground.

StyleBest forLive preview
adventurerFriendly, playful appsadventurer
adventurer-neutralFriendly, no backgroundadventurer-neutral
avataaarsCartoon-style, broad appealavataaars
avataaars-neutralCartoon, no backgroundavataaars-neutral
big-earsAnimal-style, casualbig-ears
big-ears-neutralAnimal, no backgroundbig-ears-neutral
big-smileCheerful, simplebig-smile
botttsRobots — great for AI agentsbottts
bottts-neutralRobots, no backgroundbottts-neutral
croodlesHand-drawn, scrappycroodles
croodles-neutralHand-drawn, no backgroundcroodles-neutral
dylanStylized portraits (paid)dylan
fun-emojiEmoji-style facesfun-emoji
glassFrosted glass effect (paid)glass
iconsIconographic, abstracticons
identiconGeometric, GitHub-styleidenticon
initialsLetter-based, most commoninitials
loreleiFriendly illustrated portraitslorelei
lorelei-neutralFriendly, no backgroundlorelei-neutral
micahModern minimal portraitsmicah
miniavsTiny stylized avatarsminiavs
notionistsNotion-style hand-drawnnotionists
notionists-neutralNotion-style, no backgroundnotionists-neutral
open-peepsVector illustration styleopen-peeps
personasDiverse illustrated portraitspersonas
pixel-art8-bit pixel avatarspixel-art
pixel-art-neutralPixel art, no backgroundpixel-art-neutral
ringsConcentric rings, abstractrings
shapesGeometric shapesshapes
thumbsThumbprint-style geometricthumbs

Browse all styles interactively at dicebear.com/styles. Source repo: github.com/dicebear/styles.

How to choose a style

Product typeSuggested style
Professional B2B (CRM, analytics, fin)initials (safest), or shapes/thumbs for abstract
AI assistant product (where avatar represents the AI)bottts or bottts-neutral
Consumer social / communitylorelei, notionists, or open-peeps
Game / playful productpixel-art, adventurer, big-smile, or fun-emoji
Privacy-focused / anonymous identityidenticon, rings, or shapes
Brand-led with hand-drawn feelcroodles or notionists
Minimal / Apple-like aestheticmicah or miniavs

Implementation

HTTP API (simplest)

<img
  src="https://api.dicebear.com/9.x/lorelei/svg?seed=user-id-here"
  alt="User avatar"
  width="40"
  height="40"
/>

Cache-friendly (the URL is deterministic). For production, proxy through your CDN to avoid hitting DiceBear's API on every request.

NPM (self-hosted)

npm install @dicebear/core @dicebear/lorelei
import { createAvatar } from '@dicebear/core';
import { lorelei } from '@dicebear/lorelei';
 
const avatar = createAvatar(lorelei, { seed: 'user-id-here' });
const svg = avatar.toString();

This avoids the network entirely. Recommended for any serious deployment.

React (with fallback to real photo)

function Avatar({ user, size = 40 }: AvatarProps) {
  if (user.photoUrl) {
    return <img src={user.photoUrl} alt={user.name} width={size} height={size} className="avatar" />;
  }
  
  const seed = user.id ?? user.email;
  return (
    <img
      src={`https://api.dicebear.com/9.x/lorelei/svg?seed=${encodeURIComponent(seed)}`}
      alt={user.name}
      width={size}
      height={size}
      className="avatar"
    />
  );
}

Initials that survive real names

name.split(' ')[0][0] breaks on real data: 🦊 Fox yields half a surrogate pair (�), 👩🏽‍💻 Priya splits into pieces, Christopher Montgomery III becomes CI, a name with leading, trailing or doubled spaces (Sam Lee) finds empty words, and 王秀英 has no spaces at all.

const seg = new Intl.Segmenter(undefined, { granularity: 'grapheme' });
const first = (w: string) => seg.segment(w)[Symbol.iterator]().next().value?.segment ?? '';
const words = name.trim().split(/\s+/).filter((w) => !/^(jr|sr|i{2,3}|iv)\.?$/i.test(w));
const initials = (words.length > 1 ? first(words[0]) + first(words.at(-1)!) : first(words[0] ?? '')).toLocaleUpperCase();

First and last word, by grapheme cluster, uppercased (dana → D). No usable name → the email's first grapheme, then a generic person icon. Give the image an onError that drops to this chain; a 404 must never show the broken-image glyph. flex-shrink: 0 keeps the circle round in a crowded row, and object-fit: cover handles a 4000×200 upload.

Style options & customization

Each DiceBear style accepts options (skin colors, hair styles, background colors, etc.) as URL query params:

https://api.dicebear.com/9.x/lorelei/svg?seed=Felix&backgroundColor=transparent&hair=variant01

See per-style options at dicebear.com/styles. Match the option set to your brand — e.g., restrict hair colors to your palette for tighter visual consistency.

When to apply

  • Any product where users need visual identity but real photos aren't reliably available.
  • Auto-generated avatars for AI agents or assistants.
  • Demo / staging environments where you need realistic-looking user data.
  • Public profiles where users haven't uploaded a photo.

When NOT to apply

  • Healthcare / regulated industries where avatar variation can feel unprofessional. Use initials.
  • High-trust contexts (legal, financial) where the AI-generated look might undermine credibility.
  • Products where avatar fidelity is critical (dating apps, hiring). Require real photos.

Gotcha

DiceBear's HTTP API has rate limits. For production, either:

  • Self-host via the NPM package (recommended).
  • Proxy + cache through your CDN.
  • Generate avatars server-side once per user and store as a blob.

Hitting their public API from every page load will eventually rate-limit your users.

Also: a few styles are paid (designer-contributed). Verify license per style at dicebear.com/styles before committing.

Sources

componentsavatarsdicebearidentity