Username generator. Fully typed, simple and customizable. 0 Dependencies
The lists are taken from this repo and automatically converted into json by ./generate/wordlist.js
Small website where you can see it in action and customize the output.
https://canihazusername.vercel.app/
npm i canihazusername
yarn add canihazusername
pnpm i canihazusername
import { generate } from 'canihazusername'
const username = generate()
You can of course customize the generated username. The default format string is {character}_{english}
.
import { generate } from 'canihazusername'
const username = generate('something-{character}_bot')
Basically you can use any string you want and everything between {somelist}
will be replaced from a random word from the list called somelist
.
There is a list of available words that you can use.
You can also combine multiple (as many as you wish) lists into the same braket with the |
charcter.
This will build a combined list and choose at random between all those words.
import { generate } from 'canihazusername'
const username = generate('{quantity|age|cats|}')
This example will choose a random word between the quantity
, age
and cats
list.
You can also add your own lists or owerwrite the built in one.
import { generate } from 'canihazusername'
const gits = ['gitlab', 'github', 'gitea']
const username = generate('{gits}', { lists: { gits } })
For security reasons the default limit for the maximum reformats/insertions is set to 16.
If you use more than 16 {}
you can increase them with the maxReformats
option.
import { generate } from 'canihazusername'
const username = generate('{1} {2} ... {17}', { maxReformats: 16 }) // ❌ The last one will not be replaced
const username = generate('{1} {2} ... {17}', { maxReformats: 20 }) // ✅