Skip to content

dicebear/dicebear

DiceBear Avatar Library

DiceBear is an open source avatar library. It turns any seed string (a username or an email address, for example) into an SVG avatar in one of 35+ styles designed by various artists. The same seed always produces the same avatar, so you store a string instead of an image and never ask users to upload a profile picture.

Avatars are customizable through style options: colors, backgrounds, rotation, individual features like hair or glasses.

Playground | Documentation | Editor

One library, six languages

DiceBear 10 ships as native libraries for JavaScript, PHP, Python, Rust, Go, and Dart. Every port passes a shared test suite that requires byte-identical SVG output to the JavaScript reference. Generate an avatar in the browser, regenerate it later in a Go or PHP backend, and you get the same bytes.

Language Package Install
JavaScript / TypeScript @dicebear/core npm install @dicebear/core
PHP dicebear/core composer require dicebear/core
Python dicebear-core pip install dicebear-core
Rust dicebear-core cargo add dicebear-core
Go dicebear-go go get github.com/dicebear/dicebear-go/v10
Dart dicebear_core dart pub add dicebear_core

In JavaScript it looks like this; the documentation has the equivalent for each language:

import { Avatar } from '@dicebear/core';
import definition from '@dicebear/styles/lorelei.json' with { type: 'json' };

const avatar = new Avatar(definition, {
  seed: 'John Doe',
  size: 128,
});

avatar.toString(); // SVG string
avatar.toDataUri(); // data:image/svg+xml;charset=utf-8,...

The 35+ avatar styles are plain JSON definitions from the dicebear/styles repository, available as a package for each language. You can also create your own style, with Figma or from scratch.

Without writing code

  • The HTTP API returns avatars from a plain URL, free and without an account: https://api.dicebear.com/10.x/lorelei/svg?seed=Felix. For full control and privacy you can host it yourself with a single Docker container.
  • The CLI generates avatar files in bulk: npx dicebear lorelei --count 10.
  • The editor lets you assemble a single avatar by hand and export it.

This repository

This monorepo contains the six core libraries, the CLI, the SVG-to-raster converter, the documentation site (dicebear.com), and the editor. Related projects live in their own repositories:

Contributions are welcome; CONTRIBUTING.md explains the setup and where each kind of change belongs.

License

The code is MIT licensed, including commercial use. The avatar styles are the work of their respective artists and carry their own licenses; the license overview lists them all, and many only ask for attribution.

Sponsors

Advertisement: Many thanks to our sponsors who provide us with free or discounted products.

bunny.net