Skip to content
View as Markdown

Your first avatar ​

You don't need to install anything. Every DiceBear avatar has a URL, and any <img> tag can show it:

html
<img src="https://api.dicebear.com/11.x/lorelei/svg?seed=Alice" alt="avatar" />

Two things in that URL shape the avatar: the style, here lorelei, and the seed. The style sets the look, and the seed picks one avatar within it. Alice gets the same face today, tomorrow, and on every device. Type something into the field below, watch four styles react, and click a tile to see its URL:

https://api.dicebear.com/11.x/lorelei/svg?seed=Alice
Try it

That's the whole idea. Use a username or user ID as the seed and every person in your app gets a stable avatar, without uploads and without storing images.

Pick a style ​

The four styles above are a taste of 63, drawn by different artists, from minimal geometric marks to fully illustrated characters and robots. No other avatar library offers a collection like it, and switching is one word in the URL:

html
<img src="https://api.dicebear.com/11.x/bottts/svg?seed=Alice" alt="avatar" />

Take a stroll through the style gallery: every style has its own page with live previews, and somewhere in there is the one that fits your project.

Make it yours ​

Styles come with options. Some are shared by all of them, like background color, flip, and scale, and most styles add their own on top, like hair, eyes, or accessories. Options ride along in the URL as query parameters:

html
<img
  src="https://api.dicebear.com/11.x/lorelei/svg?seed=Alice&flip=horizontal&backgroundColor=b6e3f4"
  alt="avatar"
/>

You'll find each style's options on its page in the gallery. Or skip the reading: the Playground lets you click a configuration together and copy the finished URL.

Generate avatars in your own code ​

If you'd rather create avatars locally, without a request to the API, use one of the libraries. The first lines of each example install it:

js
// npm install @dicebear/core @dicebear/styles
import { Style, Avatar } from '@dicebear/core';
import lorelei from '@dicebear/styles/lorelei.json' with { type: 'json' };

const style = new Style(lorelei);
const avatar = new Avatar(style, { seed: 'Alice' });

const svg = avatar.toString();
php
// composer require dicebear/core dicebear/styles
use Composer\InstalledVersions;
use DiceBear\Avatar;
use DiceBear\Style;

$basePath = InstalledVersions::getInstallPath('dicebear/styles');
$style = Style::fromJson(file_get_contents($basePath . '/src/lorelei.json'));

$avatar = new Avatar($style, ['seed' => 'Alice']);

$svg = (string) $avatar;
python
# pip install dicebear-core dicebear-styles
from importlib.resources import files

from dicebear import Avatar, Style

style = Style.from_json(
    files("dicebear_styles").joinpath("lorelei.json").read_text("utf-8")
)

avatar = Avatar(style, {"seed": "Alice"})

svg = avatar.to_string()
rust
// cargo add dicebear-core serde_json
// cargo add dicebear-styles --features lorelei
use dicebear_core::{Avatar, Style};
use serde_json::json;

let style = Style::from_str(dicebear_styles::LORELEI)?;
let avatar = Avatar::new(&style, json!({ "seed": "Alice" }))?;

let svg = avatar.to_svg();
go
// go get github.com/dicebear/dicebear-go/v11
// go get github.com/dicebear/styles/v11
import (
	dicebear "github.com/dicebear/dicebear-go/v11"
	"github.com/dicebear/styles/v11"
)

style, _ := dicebear.NewStyle([]byte(styles.Lorelei))
avatar, _ := dicebear.NewAvatar(style, map[string]any{"seed": "Alice"})

svg := avatar.SVG()
dart
// dart pub add dicebear_core dicebear_styles
import 'package:dicebear_core/dicebear_core.dart';
import 'package:dicebear_styles/lorelei.dart';

final style = Style.parse(lorelei);
final avatar = Avatar(style, {'seed': 'Alice'});

final svg = avatar.svg;
csharp
// dotnet add package DiceBear.Core
// dotnet add package DiceBear.Styles
using System.Text.Json.Nodes;
using DiceBear;

var style = Style.Parse(Styles.Lorelei);
var avatar = new Avatar(style, new JsonObject { ["seed"] = "Alice" });

var svg = avatar.ToSvg();

The seed Alice renders the same avatar in every language. Unsure which route fits your project? The integration picker helps you choose.

Where to next? ​

  • Want motion? 21 styles animate with plain CSS and play in a normal <img> tag.
  • Read up on options like size, background, and flip.
  • Building with a framework? There are guides for React, Vue, Svelte, and more.