Skip to content

dicebear/dicebear-go

Repository files navigation

DiceBear Core (Go)

Go 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.

Playground | Documentation

Installation

go get github.com/dicebear/dicebear-go/v10

Requires Go 1.23 or newer.

Usage

import (
	dicebear "github.com/dicebear/dicebear-go/v10"
	"github.com/dicebear/styles/v10"
)

// From a style definition (raw JSON, e.g. the pure-data styles module)
style, _ := dicebear.NewStyle([]byte(styles.Lorelei))

avatar, _ := dicebear.NewAvatar(style, map[string]any{
	"seed": "John Doe",
	"size": 128,
})

avatar.SVG()     // SVG string
avatar.DataURI() // data:image/svg+xml;charset=utf-8,...

Using the Style type

style, _ := dicebear.NewStyle([]byte(styles.Lorelei))

// Create multiple avatars from the same style
avatar1, _ := dicebear.NewAvatar(style, map[string]any{"seed": "Alice"})
avatar2, _ := dicebear.NewAvatar(style, map[string]any{"seed": "Bob"})

Sponsors

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

bunny.net

About

Go implementation of DiceBear. Read-only subtree split of dicebear/dicebear - please open issues there.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Contributors

Languages