Skip to main content

@dicebear/schema

JSON Schema definitions for DiceBear avatar styles and options.

Schemas

This package exports two JSON Schemas (Draft 07):

definition.json

Validates avatar style definitions: the files that describe how a DiceBear avatar style is structured. A definition includes:

  • canvas (required): The SVG canvas dimensions and root element tree
  • components: Named, reusable SVG components with variants. At render time, a PRNG selects one variant per component. Components can also be declared as aliases of another component via extends, producing an independently-randomized instance.
  • colors: Named color palettes. Colors can define constraints such as notEqualTo (must differ from another color) or contrastTo (picks the highest-contrast value).
  • attributes: Global SVG attributes applied to the root <svg> element
  • meta: License, creator, and source metadata

Only a safe subset of SVG elements and attributes is permitted. Event handlers, external URL references, and CSS injection patterns are explicitly blocked.

Additional documentation

https://www.dicebear.com/create-styles/definition-schema/

options.json

Validates the options object passed by users when generating an avatar. Supported properties include:

Property Type Description
seed string PRNG seed for reproducible avatars
size integer Output size in pixels (1 to 4096)
idRandomization boolean SVG ID randomization to avoid conflicts
title string Accessible title rendered as <title> and aria-label
flip string | array Mirror direction: none, horizontal, vertical, or both
rotate number | [min, max] Rotation in degrees (−360 to 360)
scale number | [min, max] Scaling factor (0 to 10, 1 = original size)
translateX number | [min, max] Horizontal offset (−1000 to 1000)
translateY number | [min, max] Vertical offset (−1000 to 1000)
borderRadius number | [min, max] Corner radius (0 = sharp, 50 = circle)
fontFamily string | array Font family for text rendering
fontWeight integer | array Font weight (1 to 1000)
tags string | string[] Keep only variants carrying these tags (category or category:value, ! disallows)
animation boolean Plays the style's animations, off by default
animationSpeed number | [min, max] Playback speed multiplier (0.1 to 10, 1 = as authored)
animationDelay number | [min, max] Start offset in seconds (-3600 to 3600), added after the speed applies
*Animation boolean Switches one animation by name, wins over animation
*AnimationSpeed number | [min, max] Playback speed of one animation by name, wins over animationSpeed
*AnimationDelay number | [min, max] Start offset of one animation by name, wins over animationDelay
*Variant string | string[] | object Component variant filter and weights
*Probability number Component display probability (0 to 100)
*Color string | array Hex colors
*ColorFill string | array Color fill: solid, linear, or radial
*ColorFillStops integer | [min, max] Gradient color stops (min 2)
*ColorAngle number | [min, max] Gradient angle (−360 to 360)
*ColorOrder string random shuffles the colors per seed, fixed keeps the given order

When an option accepts an array, the PRNG either picks from the list (for discrete values) or picks a value within the range (for numeric min/max pairs).

Usage

JavaScript

npm install @dicebear/schema
import definitionSchema from "@dicebear/schema/definition.json" with { type: "json" };
import optionsSchema from "@dicebear/schema/options.json" with { type: "json" };

PHP

composer require dicebear/schema
$basePath = \Composer\InstalledVersions::getInstallPath('dicebear/schema');

$definition = json_decode(file_get_contents($basePath . '/src/definition.json'), true);
$options    = json_decode(file_get_contents($basePath . '/src/options.json'), true);

Python

pip install dicebear-schema
import json
from importlib.resources import files

definition = json.loads(files("dicebear_schema").joinpath("definition.json").read_text("utf-8"))
options    = json.loads(files("dicebear_schema").joinpath("options.json").read_text("utf-8"))

Rust

cargo add dicebear-schema

The schemas are embedded at compile time and exposed as raw JSON (&'static str). Parse them with serde_json and validate with the jsonschema crate:

use dicebear_schema::{DEFINITION, OPTIONS};

let definition: serde_json::Value = serde_json::from_str(DEFINITION)?;
let options: serde_json::Value = serde_json::from_str(OPTIONS)?;

// Or look one up by name (None if unknown); all() lists the names:
let schema = dicebear_schema::get("definition");
let all = dicebear_schema::all();

Go

go get github.com/dicebear/schema/v2

The schemas are embedded at compile time and exposed as raw JSON (string). Parse them with encoding/json and validate with a library such as jsonschema:

import (
	"encoding/json"

	"github.com/dicebear/schema/v2"
)

var definition map[string]any
_ = json.Unmarshal([]byte(schema.Definition), &definition)

var options map[string]any
_ = json.Unmarshal([]byte(schema.Options), &options)

// Or look one up by name (ok is false if unknown); All() lists the names:
raw, ok := schema.Get("definition")
all := schema.All()

Dart

dart pub add dicebear_schema

The schemas are embedded as Dart string constants. Parse them with dart:convert and validate with a package such as json_schema:

import 'dart:convert';

import 'package:dicebear_schema/dicebear_schema.dart' as schema;

final definitionSchema = jsonDecode(schema.definition);
final optionsSchema = jsonDecode(schema.options);

// Or look one up by name (null if unknown); `all` lists the names:
final raw = schema.get('definition');
final names = schema.all;

C#

dotnet add package DiceBear.Schema

The schemas are embedded in the assembly and exposed as raw JSON (string). Parse them with System.Text.Json and validate with a library such as JsonSchema.Net:

using System.Text.Json.Nodes;

var definitionSchema = JsonNode.Parse(DiceBear.Schema.Definition);
var optionsSchema = JsonNode.Parse(DiceBear.Schema.Options);

// Or look one up by name (null if unknown). All() lists the names:
var raw = DiceBear.Schema.Get("definition");
var names = DiceBear.Schema.All();

CDN

The schemas are available directly via CDN, so no installation is required. We recommend using a specific version to ensure stability:

https://cdn.hopjs.net/npm/@dicebear/schema@2.0.2/dist/definition.min.json
https://cdn.hopjs.net/npm/@dicebear/schema@2.0.2/dist/options.min.json

Contributing

See CONTRIBUTING.md for local development, testing, and the release process.

Sponsors

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

bunny.net

Metadata

Release files for dicebear-schema 2.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dicebear-schema 2.0.2
File Size Uploaded Provenance
dicebear_schema-2.0.2.tar.gz 17.2 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for dicebear-schema 2.0.2
File Interpreter ABI Platform
dicebear_schema-2.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 35.7 kB

Release files / dicebear_schema-2.0.2.tar.gz

Download URL dicebear_schema-2.0.2.tar.gz
Size 17.2 kB
Tags Source
SHA-256 checksum
How to use checksums
927317230c85ae2c98d9cd886c6e11245ce6f2084b93a3dd9251971cc5654d98
BLAKE2b-256 checksum
How to use checksums
68942569ed57ad51c6c32013e0904a1015f7a0ebb6fba24b3b9bc06d0c0d64e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 3, 2026.

Transparency log

Release files / dicebear_schema-2.0.2-py3-none-any.whl

Download URL dicebear_schema-2.0.2-py3-none-any.whl
Size 18.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e9589670cc2a3526c876bc7103545c4e97f6cab52a37963d29f0c9557c34baed
BLAKE2b-256 checksum
How to use checksums
9624bab71e0e5cfcdf5e3edd264fc78eb9e742a87c0d16ba73eb72685dc0ae41
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 3, 2026.

Transparency log

Security for dicebear-schema 2.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for dicebear_schema-2.0.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 3, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page