JSON Schema definitions for DiceBear avatar styles and options
Project description
@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 treecomponents— 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 viaextends, producing an independently-randomized instance.colors— Named color palettes. Colors can define constraints such asnotEqualTo(must differ from another color) orcontrastTo(picks the highest-contrast value).attributes— Global SVG attributes applied to the root<svg>elementmeta— 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/specification/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) |
title |
string |
Accessible title rendered as <title> and aria-label |
flip |
string | array |
Mirror direction: none, horizontal, vertical, or both |
scale |
number | [min, max] |
Scaling factor (0 to 10, 1 = original size) |
rotate |
number | [min, max] |
Rotation in degrees (−360 to 360) |
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) |
idRandomization |
boolean |
SVG ID randomization to avoid conflicts |
fontFamily |
string | array |
Font family for text rendering |
fontWeight |
integer | array |
Font weight (1 to 1000) |
*Probability |
number |
Component display probability (0 to 100) |
*Variant |
string | string[] | object |
Component variant filter and weights |
*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) |
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"))
CDN
The schemas are available directly via CDN — no installation required. We recommend using a specific version to ensure stability:
https://cdn.hopjs.net/npm/@dicebear/schema@1.1.0-rc.2/dist/definition.min.json
https://cdn.hopjs.net/npm/@dicebear/schema@1.1.0-rc.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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dicebear_schema-1.1.0rc2.tar.gz.
File metadata
- Download URL: dicebear_schema-1.1.0rc2.tar.gz
- Upload date:
- Size: 12.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
61636d1b1fab5445e85e249d3beab610b3987d5262bf3af549e0a3a3bf5c2ea8
|
|
| MD5 |
1741d784f298f9747d96e5dbd3a15ef0
|
|
| BLAKE2b-256 |
1792c78e70e436e8bf266fe5806d65a95828f93d4cdc2ad4fb207dd7d379f009
|
Provenance
The following attestation bundles were made for dicebear_schema-1.1.0rc2.tar.gz:
Publisher:
publish.yml on dicebear/schema
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dicebear_schema-1.1.0rc2.tar.gz -
Subject digest:
61636d1b1fab5445e85e249d3beab610b3987d5262bf3af549e0a3a3bf5c2ea8 - Sigstore transparency entry: 1685763546
- Sigstore integration time:
-
Permalink:
dicebear/schema@cd28359f3372b022ea3d7b97a8c1d2f3eba56aa7 -
Branch / Tag:
refs/tags/v1.1.0-rc.2 - Owner: https://github.com/dicebear
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@cd28359f3372b022ea3d7b97a8c1d2f3eba56aa7 -
Trigger Event:
push
-
Statement type:
File details
Details for the file dicebear_schema-1.1.0rc2-py3-none-any.whl.
File metadata
- Download URL: dicebear_schema-1.1.0rc2-py3-none-any.whl
- Upload date:
- Size: 13.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3dd5ca030ab7395b0f6ceaf147bdefd94a8cbfc996475bf69e13e953c878439c
|
|
| MD5 |
c4f0bc7aface10c346c57150b175b8a9
|
|
| BLAKE2b-256 |
ae96a79fb4bc99d03cc67691512798f388998787eef61ea57b1ab0c328db8eef
|
Provenance
The following attestation bundles were made for dicebear_schema-1.1.0rc2-py3-none-any.whl:
Publisher:
publish.yml on dicebear/schema
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dicebear_schema-1.1.0rc2-py3-none-any.whl -
Subject digest:
3dd5ca030ab7395b0f6ceaf147bdefd94a8cbfc996475bf69e13e953c878439c - Sigstore transparency entry: 1685763615
- Sigstore integration time:
-
Permalink:
dicebear/schema@cd28359f3372b022ea3d7b97a8c1d2f3eba56aa7 -
Branch / Tag:
refs/tags/v1.1.0-rc.2 - Owner: https://github.com/dicebear
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@cd28359f3372b022ea3d7b97a8c1d2f3eba56aa7 -
Trigger Event:
push
-
Statement type: