Thanks for considering a contribution to @dicebear/schema.
This repository holds the JSON Schemas (Draft 07) that describe DiceBear avatar style definitions and the options object consumers pass at render time. The core library, the API, the definitions repo, the Figma exporter, and third-party integrations all validate against these two files, so schema changes tend to land in several repos at once.
- Bug fixes and small improvements: a pull request is fine.
- Anything that changes the shape of
definition.jsonoroptions.json(new fields, renames, stricter constraints, removed keywords): open an issue first. Schema changes affect the core library, the API, the definitions repo, the Figma exporter, and every third-party integration, so the coordination matters more than the diff. - Security issues go to contact@dicebear.com privately, not into a public issue.
- Everyone participating is expected to follow the Code of Conduct.
- Node.js 20 or newer
git clone https://github.com/dicebear/schema.git
cd schema
npm install| Script | What it does |
|---|---|
npm run build |
Runs scripts/build.sh to produce dist/*.min.json and lib/dicebear_schema.dart |
npm test |
Runs the Node built-in test runner against tests/ |
npm run format |
Runs Prettier on the whole repo |
npm run format:check |
Checks formatting without writing |
src/
├── definition.json # Schema for avatar style definitions
└── options.json # Schema for the user-supplied options object
lib/
└── dicebear_schema.dart # Generated Dart shim embedding src/*.json (git-ignored)
tests/
├── definition/ # Fixtures that must validate against definition.json
├── options/ # Fixtures that must validate against options.json
├── standalone/ # Self-contained schema/fixture pairs
└── helpers/ # Ajv helpers shared by the suites
tool/
└── check_parity.dart # CI guard: embedded Dart constants == src/*.json bytes
scripts/
├── build.sh # Builds the minified dist files and the Dart shim
├── sync-readme.sh # Keeps the README CDN links in sync with the version
└── version.sh # Bumps all four manifests and tags a release
The schemas also ship to PyPI as the data-only dicebear-schema package
(pyproject.toml), the Python counterpart of the npm and Composer
distributions. It carries no Python code: the same src/*.json files are
exposed under the dicebear_schema import name and read by the consumer with
the standard library.
- Edit the relevant schema in
src/. - Add a test fixture in
tests/definition/ortests/options/:valid/*.jsonfixtures must pass validation.invalid/*.jsonfixtures must fail validation.
- Run
npm test. The suite uses Ajv withajv-formats; failures point at the offending fixture and keyword. - Run
npm run buildto refresh the generated files. Both outputs are git-ignored: only the npm publish shipsdist/*.min.json, and only the pub.dev publish shipslib/dicebear_schema.dart; each publish builds its output fresh fromsrc/. - Run
npm run formatbefore you open the pull request.
- Keep the two files separate:
definition.jsondescribes the style file shipped by@dicebear/definitions;options.jsondescribes runtime options accepted by@dicebear/core. Avoid adding fields in the wrong one. options.jsonuses wildcard property names (*Variant,*Color,*Rotate, …) that@dicebear/coreexpands per component. If you add a new wildcard, follow the existingpatternPropertiespattern.- Only a narrow set of SVG elements and attributes is allowed in definitions. Event handlers, external URLs, and CSS-injection patterns must stay blocked.
- Prettier formats everything (
.prettierrcis in the repo root). - JSON files use two-space indentation (Prettier default).
- Keep schema keys in a consistent order within each object; run
npm run formatand let Prettier settle the rest.
Publishing is fully automated via the publish workflow. To cut a release, bump the version across all four manifests and tag it:
scripts/version.sh <version> # e.g. 1.1.0 or 1.1.0-rc.1
git push && git push --tagsscripts/version.sh updates version in package.json, pyproject.toml,
Cargo.toml and pubspec.yaml, syncs the README CDN links
(scripts/sync-readme.sh) and package-lock.json, then creates the commit and
the v<version> tag. All four manifests carry the same version, so always
release via this script (not npm version, which would bump only
package.json).
On the tag, the workflow:
- Runs the schema tests and builds the minified dist files.
- Publishes to npm with provenance (
@dicebear/schema). - Builds the data-only wheel from
src/and publishes to PyPI via Trusted Publishing (dicebear-schema). - Publishes the Rust crate to crates.io via Trusted Publishing
(
dicebear-schema). - Publishes the Dart package to pub.dev via the GitHub Actions integration
(
dicebear_schema). This requires automated publishing to be enabled in the pub.dev admin settings for the package (repositorydicebear/schema, tag patternv{{version}}).
Packagist (dicebear/schema) and the Go module proxy
(github.com/dicebear/schema) both pick up the same Git tag automatically, with
no publish step. The Go version lives entirely in the tag, so scripts/version.sh
does not touch go.mod. For prereleases, note that PyPI normalizes to PEP 440, so
npm publishes 1.1.0-rc.1 while PyPI publishes 1.1.0rc1.
Major version bumps and Go. Go encodes the major version in the import path. While this repo is on
v0/v1the module path staysgithub.com/dicebear/schema(no suffix). When it moves tov2, thego.modmodule path must gain a/v2suffix by hand (and the README import examples updated).scripts/version.shonly rewrites the semver in the npm/PyPI/crates/pub manifests, not the Go module path.
By opening a pull request you agree that your contribution is released under the repository's MIT license.