npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

avatarka

v1.1.0

Published

SVG avatar generators with multiple themes

Readme

avatarka

Demo

Generate unique, customizable SVG avatars with multiple themes. Zero runtime dependencies.

Features

  • 6 Built-in Themes: Geometric patterns, monsters, animals, people, robots, and aliens
  • Seed-based Generation: Generate deterministic avatars from any string (email, user ID, etc.)
  • Fully Customizable: Every parameter can be tweaked via a typed API
  • Zero Dependencies: No runtime dependencies
  • TypeScript First: Full type safety with exported types

Installation

npm install avatarka

Quick Start

Basic Usage

import { generateAvatar, generateParams } from 'avatarka';

// Generate random parameters and create an avatar
const params = generateParams('monsters');
const svg = generateAvatar('monsters', params);

// Insert into DOM
document.getElementById('avatar').innerHTML = svg;

Seed-based Generation

Generate consistent avatars from any string (great for user avatars):

import { randomAvatar, generateParams } from 'avatarka';

// One-liner: generate avatar from seed
const svg = randomAvatar('animals', '[email protected]');

// Same seed always produces the same avatar
const params1 = generateParams('geometric', 'user-123');
const params2 = generateParams('geometric', 'user-123');
// params1 and params2 are identical

API Reference

generateAvatar(theme, params)

Generate an SVG string from theme and parameters.

const svg = generateAvatar('robots', {
  backgroundShape: 'circle',
  bodyColor: '#95a5a6',
  accentColor: '#3498db',
  eyeColor: '#e74c3c',
  backgroundColor: '#2c3e50',
  headShape: 'square',
  antennaStyle: 'single',
  eyeStyle: 'round',
  mouthStyle: 'grille',
  hasPanel: 'no',
  panelLights: 3,
});

generateParams(theme, seed?)

Generate random parameters for a theme. Optionally pass a seed for deterministic output.

// Random
const params = generateParams('geometric');

// Deterministic
const params = generateParams('geometric', 'my-seed');

randomAvatar(theme, seed?)

Convenience function combining generateParams and generateAvatar.

const svg = randomAvatar('people', '[email protected]');

getDefaultParams(theme)

Get default parameters from the theme schema.

const defaults = getDefaultParams('monsters');

getThemeNames()

Get array of available theme names.

const themes = getThemeNames(); // ['people', 'animals', 'monsters', 'robots', 'aliens', 'geometric']

getTheme(theme)

Get theme metadata including name and parameter schema.

const { name, schema } = getTheme('animals');

Themes

| Theme | Description | |-------------|-----------------------------------------------------------------------------------------| | geometric | Abstract patterns with shapes like triangles, circles, squares, and hexagons | | monsters | Cute monster characters with customizable features | | animals | Animal faces (cats, dogs, bears, bunnies, foxes, pandas, owls, koalas, penguins, lions) | | people | Human avatars with various hairstyles and accessories | | robots | Retro-futuristic robot heads with various features | | aliens | Extraterrestrial beings with various head shapes |

PNG Generation (Browser-only)

Convert SVG avatars to PNG using the Canvas API:

import { generateAvatar, generateParams, svgToPng, svgToPngDataUrl } from 'avatarka';

const params = generateParams('monsters', '[email protected]');
const svg = generateAvatar('monsters', params);

// Get as PNG Blob
const blob = await svgToPng(svg, { size: 512 });

// Or as data URL
const dataUrl = await svgToPngDataUrl(svg, { size: 128 });

Note: These functions require a browser environment with Canvas support.

Related Packages

License

MIT