PHPackages                             dicebear/schema - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. dicebear/schema

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

dicebear/schema
===============

JSON Schema definitions for DiceBear avatar styles and options

v1.3.0(1w ago)08.8k1MITJavaScriptCI passing

Since Feb 26Pushed 1w agoCompare

[ Source](https://github.com/dicebear/schema)[ Packagist](https://packagist.org/packages/dicebear/schema)[ Docs](https://github.com/dicebear/schema)[ RSS](/packages/dicebear-schema/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (34)Used By (1)

@dicebear/schema
================

[](#dicebearschema)

JSON Schema definitions for [DiceBear](https://dicebear.com) avatar styles and options.

Schemas
-------

[](#schemas)

This package exports two JSON Schemas (Draft 07):

### `definition.json`

[](#definitionjson)

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 `` 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

[](#additional-documentation)

### `options.json`

[](#optionsjson)

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

PropertyTypeDescription`seed``string`PRNG seed for reproducible avatars`size``integer`Output size in pixels (1 to 4096)`title``string`Accessible title rendered as `` 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
-----

[](#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`](https://crates.io/crates/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
```

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`](https://github.com/santhosh-tekuri/jsonschema):

```
import (
	"encoding/json"

	"github.com/dicebear/schema"
)

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`](https://pub.dev/packages/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;
```

**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@1.3.0/dist/definition.min.json
https://cdn.hopjs.net/npm/@dicebear/schema@1.3.0/dist/options.min.json

```

Contributing
------------

[](#contributing)

See [CONTRIBUTING.md](https://github.com/dicebear/schema/blob/main/CONTRIBUTING.md) for local development, testing, and the release process.

Sponsors
--------

[](#sponsors)

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

[    ![bunny.net](https://camo.githubusercontent.com/4ae34db3dad914c12edc4dc985f9c62d3d4cde77d4d6de3471bd9211c42ac5c2/68747470733a2f2f7777772e64696365626561722e636f6d2f73706f6e736f72732f62756e6e792d6461726b2e737667) ](https://bunny.net/)

###  Health Score

46

—

FairBetter than 92% of packages

Maintenance94

Actively maintained with recent releases

Popularity22

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 88.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~3 days

Total

33

Last Release

13d ago

Major Versions

v0.16.0 → v1.0.02026-05-17

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/647303?v=4)[Florian Körner](/maintainers/FlorianKoerner)[@FlorianKoerner](https://github.com/FlorianKoerner)

---

Top Contributors

[![FlorianKoerner](https://avatars.githubusercontent.com/u/647303?v=4)](https://github.com/FlorianKoerner "FlorianKoerner (96 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (12 commits)")

---

Tags

schemajson-schemaavatarDiceBear

### Embed Badge

![Health badge](/badges/dicebear-schema/health.svg)

```
[![Health](https://phpackages.com/badges/dicebear-schema/health.svg)](https://phpackages.com/packages/dicebear-schema)
```

###  Alternatives

[league/config

Define configuration arrays with strict schemas and access values with dot notation

565335.0M36](/packages/league-config)[laravolt/avatar

Turn name, email, and any other string into initial-based avatar or gravatar.

2.0k5.8M39](/packages/laravolt-avatar)[torann/json-ld

Extremely simple JSON-LD markup generator.

149641.1k1](/packages/torann-json-ld)[yohang88/letter-avatar

Generate user avatar using name initials letter.

126584.2k3](/packages/yohang88-letter-avatar)[brick/schema

Schema.org library for PHP

5184.5k1](/packages/brick-schema)[tomloprod/radiance

A deterministic mesh gradient avatar generator for PHP.

14010.2k](/packages/tomloprod-radiance)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
