Skip to content

fluent-cart/text-avatars

Repository files navigation

TextAvatars

Beautiful, privacy-first avatar generation API. Generate stunning avatars with initials from any name.

Deploy to Cloudflare Workers License: MIT

TextAvatars

Live DemoQuick StartAPI ReferenceSelf-Hosting


Why TextAvatars?

  • Privacy First — No tracking, no cookies, no data storage. We never see or store your users' names.
  • Blazing Fast — Served from 300+ edge locations worldwide via Cloudflare Workers.
  • Free & Open Source — No API keys, no rate limits, no signup required. MIT licensed.
  • SVG Output — Crisp at any resolution, tiny file sizes, perfect for retina displays.
  • Fully Customizable — Colors, sizes, fonts, shapes. Make avatars that match your brand.

Quick Start

Just use it as an image source. No signup, no API keys.

<img src="https://textavatars.com/api?name=John+Doe" alt="John Doe">

With Custom Styling

<img
  src="https://textavatars.com/api?name=Sarah+Chen&background=6366f1&color=fff&rounded=true&bold=true"
  width="64"
  height="64"
  alt="Sarah Chen"
>

React Component

function Avatar({ name, size = 48 }) {
  const params = new URLSearchParams({
    name,
    size,
    background: 'random',
    rounded: true,
    bold: true
  });

  return (
    <img
      src={`https://textavatars.com/api?${params}`}
      width={size}
      height={size}
      alt={name}
    />
  );
}

API Reference

Endpoint

GET https://textavatars.com/api

Parameters

Parameter Default Description
name John Doe Name to generate initials from
size 64 Image size in pixels (16-512)
background f0e9e9 Background color (hex without #) or random
color auto Text color (hex). Auto-contrasts if not set
length 2 Number of initials to display
font-size 0.5 Font size as ratio of image (0.1-1.0)
rounded false Circular avatar (true/false)
bold false Bold text (true/false)
uppercase true Uppercase initials (true/false)

Examples

# Basic
https://textavatars.com/api?name=John+Doe

# Custom colors
https://textavatars.com/api?name=Alice&background=ec4899&color=fff

# Random background (deterministic per name)
https://textavatars.com/api?name=Bob&background=random

# Circular, bold, large
https://textavatars.com/api?name=Jane+Smith&rounded=true&bold=true&size=128

Self-Hosting

TextAvatars is designed to be easily self-hosted on Cloudflare Workers.

Prerequisites

Deploy

  1. Clone the repository

    git clone https://github.com/yourusername/textavatars.git
    cd textavatars
  2. Install dependencies

    npm install
  3. Login to Cloudflare

    npx wrangler login
  4. Deploy

    npm run deploy

Your worker will be available at https://textavatars.<your-subdomain>.workers.dev

Custom Domain

To use a custom domain, update wrangler.toml:

routes = [
  { pattern = "avatars.yourdomain.com/*", zone_name = "yourdomain.com" }
]

Cost

TextAvatars is extremely cost-effective to run:

Monthly Requests Estimated Cost
Up to 3 million Free
10 million ~$5
100 million ~$32

With caching, your actual costs will be significantly lower.


Privacy

We take privacy seriously:

  • No cookies — Ever.
  • No tracking — No analytics, no pixels, no fingerprinting.
  • No data storage — Names are processed in memory and immediately discarded.
  • No logs — Unless you explicitly enable them for your self-hosted instance.
  • Stateless — Every request is independent. We don't know who you are.

Your users' names never touch a database. They're rendered into an SVG and forgotten.


Contributing

Contributions are welcome! Whether it's:

  • Bug reports
  • Feature requests
  • Documentation improvements
  • Code contributions

Please feel free to open an issue or submit a pull request.

Development

# Install dependencies
npm install

# Start local development server
npm run dev

# Run type checking
npx tsc --noEmit

License

MIT License — feel free to use this in personal and commercial projects.


Acknowledgments

Inspired by ui-avatars.com by Lasse Rafn.


Built with care using Cloudflare Workers

About

Beautiful, privacy-first avatar generation API. Generate stunning avatars with initials from any name.

Topics

Resources

Stars

Watchers

Forks

Contributors