unique-names-generator

A zero-dependency, tree-shakeable library for generating random or seeded unique name strings from built-in or custom word dictionaries.

Library
npm
v4.7.1
689stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
41/100Fair
Development Activity0
Maintenance20
Community56
Maturity60
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
64/100Good
Architecture72
Code Quality68
Innovation55
Learning Curve60

unique-names-generator is a small TypeScript utility for producing human-readable, memorable name strings by combining words drawn from dictionaries — adjectives, animals, colors, countries, names, languages, and Star Wars characters ship built in, and any array of strings can be supplied as a custom dictionary. Names are assembled by picking one word per dictionary (up to a configurable length) and joining them with a separator, with three casing styles (lowerCase, upperCase, capital) and an optional NumberDictionary helper for appending random numeric suffixes.

Generation can be fully random (Math.random) or deterministic: passing a numeric or string seed drives an internal mulberry32 pseudo-random generator so the same seed always reproduces the same name, which is useful for testing or content that must be stable across runs. The library has zero runtime dependencies, ships CommonJS, ESM, and UMD builds via microbundle, and marks itself side-effect-free so bundlers can tree-shake unused dictionaries out of the final bundle.

What You Get

  • uniqueNamesGenerator() - a single factory function that assembles a name string from an ordered array of dictionaries.
  • Seven built-in dictionaries - adjectives, animals, colors, countries, languages, names, and Star Wars characters, each importable independently for tree-shaking.
  • NumberDictionary helper - generates numeric-string arrays with a configurable min/max range or fixed digit length for numeric suffixes.
  • Deterministic seeding - a numeric or string seed reproduces the exact same generated name every time via an internal mulberry32 PRNG.
  • Full TypeScript typings - exported Config interface and typed dictionary exports, usable directly with no separate @types package.

Common Use Cases

  • Anonymous session names - assign a friendly display name like red_clever_panda to a guest user or anonymous session.
  • Test fixture data - generate readable placeholder names for seed data and fixtures in tests and demos.
  • Docker/VM-style resource naming - produce human-memorable identifiers for containers, branches, or temporary resources.
  • Reproducible demo content - use a fixed seed to generate the same sample names across CI runs or documentation screenshots.

Under The Hood

Architecture The public surface is a thin functional facade: uniqueNamesGenerator() in src/unique-names-generator.ts validates the caller-supplied config (throwing a descriptive error if dictionaries is missing) and delegates to the UniqueNamesGenerator class in src/unique-names-generator.constructor.ts, which owns all generation state behind private class fields (#dictionaries, #length, #separator, #style, #seed, #tmpSeed) and exposes a single generate() method that reduces over a slice of the dictionaries array, picking one word per dictionary via #getRandomFloat() and formatting it via #format(). Randomness itself is isolated in src/seed.ts, a standalone mulberry32 implementation the class falls back to only when a seed is provided (otherwise it uses Math.random()). Word lists live under src/dictionaries/ as independent modules re-exported from a single index.ts, keeping data cleanly separated from generation logic; changing the core class’s private state shape or the seed algorithm would only require touching this one file, since nothing else reaches into its internals.

Tech Stack Written entirely in TypeScript with zero runtime dependencies — every dependency in package.json is a devDependency. Builds are produced by microbundle, which emits CommonJS (dist/index.js), ESM (dist/index.m.js), and UMD (dist/index.umd.js) bundles plus .d.ts declarations from a single src/index.ts source entry, and the package sets sideEffects: false so consuming bundlers can tree-shake unused dictionary exports. Tests run under Jest with babel-jest (via @babel/preset-env and @babel/preset-typescript) rather than ts-jest, and np handles versioned releases.

Code Quality Three test files (unique-names-generator.test.ts, unique-names-generator.constructor.test.ts, seed.test.ts) plus a Jest snapshot file give reasonably thorough coverage: the main suite exercises separators, casing styles, custom and combined dictionaries, short-mode length, emoji separators, and the NumberDictionary helper, while seed.test.ts uses it.each over dozens of fixed seed/expected-index pairs to lock down PRNG determinism, and one case asserts the thrown error via toThrowErrorMatchingInlineSnapshot. Errors are explicit and descriptive (missing dictionaries, invalid length, length exceeding dictionary count) rather than swallowed. Naming is consistent camelCase with private-field (#) encapsulation, and ESLint (typescript-eslint) plus Prettier are configured for lint/format enforcement. CI is thin, though: the only GitHub Actions workflow present is CodeQL scanning, with test execution left to a stale Travis config (.travis.yml, Node 14) that Travis CI itself deprecated for open-source use — so it’s unclear tests are actually enforced on every push today.

What Makes It Unique Most random-name generators are purely non-deterministic; this one’s defining choice is a self-contained mulberry32 PRNG that’s reseeded on every generate() call, so supplying the same numeric or string seed always reproduces the identical name across runs and environments — useful for reproducible tests, fixtures, and demos without pulling in an external RNG dependency. Combined with per-dictionary tree-shaking and a same-shape custom-dictionary API (any string[] works exactly like a built-in one), the library stays a small, composable primitive rather than a batteries-included framework.

Used by 6 apps in this directory

Go
75%
AGPL 3.0

Coder

Devops · Developer Tools · Code Editors

14,385

Self-hosted cloud development environments and AI coding agents — defined in Terraform, connected via WireGuard, automatically shut down when idle.

View details
93
Repo Health
90
Technical
68
Dependency
Built with
Go75%
TypeScript23%
Updated today
TypeScript
100%
Other

Dub

Marketing · Analytics

24,676

The open-source link attribution platform for short links, conversion tracking, and affiliate programs — powering 100M+ clicks monthly.

View details
80
Repo Health
78
Technical
62
Dependency
Built with
TypeScript100%
Updated 2 days ago
Go
60%
MIT

hoop

Security · Monitoring

807

A wire-protocol gateway that enforces data masking, command blocking, approval workflows, and full session recording for engineers and AI agents accessing production infrastructure.

View details
85
Repo Health
80
Technical
64
Dependency
Built with
Go60%
Clojure19%
JavaScript14%
Updated 3 days ago
TypeScript
96%
Other

Lightdash

Analytics · Data Engineering

6,119

The open-source Looker alternative that turns your dbt project's metrics and dimensions into governed, self-serve charts and dashboards — no license key required.

View details
93
Repo Health
84
Technical
64
Dependency
Built with
TypeScript96%
Updated yesterday
TypeScript
64%
Other

NocoDB

No Code Platforms · Databases · Low Code Platforms

64,861

Turn any SQL database into a collaborative no-code spreadsheet with automatic REST APIs and real-time views.

View details
90
Repo Health
77
Technical
62
Dependency
Built with
TypeScript64%
Vue31%
Updated 2 days ago
TypeScript
88%
AGPL 3.0

OpenPanel

Analytics

6,884

Open-source Mixpanel alternative with session replay, MCP integration, and privacy-first product analytics you fully control.

View details
74
Repo Health
74
Technical
68
Dependency
Built with
TypeScript88%
Updated 3 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search