You've finished building a neat little utility. You open a terminal, type npm publish, and then… stall. What do you name the thing?
You try json-stream-parser — taken. stream-json-parser — also taken. parse-json-stream — taken too, and it's a completely different package. You spend 20 minutes bouncing between the npm registry website and your terminal before settling on something you're not even happy with.
I've been through that loop more times than I'd like to admit, so I built a small tool to short-circuit it: gen-package-name.
What it does
gen-package-name is a CLI utility that:
- Asks you for a short description of your package (or accepts keywords directly)
- Extracts meaningful keywords from that description
- Generates a set of name candidates using those keywords
- Checks each candidate against the npm registry in real time
- Lets you regenerate until you find something you like
The whole flow takes about 30 seconds.
Getting started
Install globally:
npm install -g gen-package-name
Or just run it once with npx:
npx gen-package-name
Interactive mode (the happy path)
Run it with no arguments and it walks you through everything:
gen-package-name
You'll be prompted for a description like "parse json streams efficiently". It strips stop words, extracts the signal (parse, json, streams), and generates 5 name candidates using a mix of patterns — adjective-noun, verb-noun, noun-type, and combinations like verb-keyword-cli. Each candidate gets checked against the registry and marked available or taken.
If you don't love the batch, you can regenerate as many times as you want. When you pick a name that's already taken, it fetches and prints the existing package's metadata so you know what you're up against.
Non-interactive and CI-friendly modes
For scripting and pipelines, there are a few flags worth knowing:
Generate names from a description, no prompts:
gen-package-name -d "http request retry logic" -n
Pass keywords directly, show only available names, output JSON:
gen-package-name -k http,retry,fetch -c 10 -a -j
The JSON output is machine-readable, so you can pipe it into other tools or use it in a script that automates your publish workflow.
Quick availability check for a specific name:
gen-package-name --check my-package-name
Fetch registry metadata for any existing package:
gen-package-name --info chalk --json
How the name generation works
The generator builds name candidates by randomly combining words from several pools:
-
Adjectives — words like
tiny,fast,safe,sharp -
Verbs — words like
parse,watch,build,resolve - Nouns — a curated list plus your own keywords injected at the top
-
Package type suffixes —
lib,cli,kit,util,core, and so on
The patterns it uses are the same conventions that popular npm packages already follow: adjective-noun (tiny-emitter, fast-glob), verb-noun (parse-json, watch-config), and noun-type (router-kit, cache-lib). When you supply two or more keywords, it also generates keyword-keyword pairs — things like http-client or auth-token — which tend to be the most memorable names.
Candidates are validated against npm's naming rules before they're even checked against the registry (lowercase alphanumeric and hyphens, no leading/trailing hyphens, max 214 chars), so you never get back something that would fail at publish time anyway.
Full CLI reference
Usage: gen-package-name [options]
Options:
-V, --version print version and exit
-d, --description describe the package (keywords extracted automatically)
-k, --keywords <list> comma- or space-separated keyword seeds
-c, --count <n> number of names to generate (default: 5)
-a, --available-only only output names available on npm
-j, --json emit machine-readable JSON
-n, --non-interactive skip prompts; print results and exit
--check <name> check whether a specific name is available
--info <name> fetch npm registry metadata for a package
--no-color disable colored output
-h, --help display help
Stack
The package is written in TypeScript, targets Node.js ≥ 16, and uses:
- Commander.js for argument parsing
- Inquirer for the interactive prompts
- chalk for colored output
- package-json to query the npm registry
No exotic dependencies, no network calls beyond the registry lookups.
Links
Hope it saves you at least one naming spiral. 🛠️
Top comments (0)