Package Exports
- @dicebear/core
Readme
DiceBear Core (JavaScript)
JavaScript implementation of the DiceBear avatar library. Generates deterministic SVG avatars from style definitions and a seed string.
DiceBear is available for multiple languages. All implementations share the same PRNG and rendering pipeline, producing identical SVG output for the same seed, style, and options, regardless of the language used.
Installation
npm install @dicebear/coreRequires Node.js 22+ or any modern browser.
Usage
import { Avatar } from '@dicebear/core';
// From a style definition (here from the @dicebear/styles package)
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,...Using the Style class
import { Style, Avatar } from '@dicebear/core';
const style = new Style(definition);
// Create multiple avatars from the same style
const avatar1 = new Avatar(style, { seed: 'Alice' });
const avatar2 = new Avatar(style, { seed: 'Bob' });Sponsors
Advertisement: Many thanks to our sponsors who provide us with free or discounted products.