# better-username-generator

> Generate random usernames based on your own custom templates and rules

Latest version **1.1.0** (published 2023-08-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install better-username-generator
pnpm add better-username-generator
yarn add better-username-generator
bun add better-username-generator
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2023-08-12 |
| First published | 2023-08-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=10 |
| Dependencies | 0 |
| Unpacked size | 473.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Freddie Nelson |
| Maintainers | freddie-nelson |
| Keywords | random, username, generator |

## Links

- npm: https://www.npmjs.com/package/better-username-generator
- Repository: https://github.com/freddie-nelson/username-generator
- Issues: https://github.com/freddie-nelson/username-generator/issues
- npm.io page: https://npm.io/package/better-username-generator

## Recent versions

- 1.1.0 (latest) — 2023-08-12
- 1.0.0 — 2023-08-12

## README

<h1 style="display: flex; justify-content: space-between; align-items: center;">
  🔥 Better Username Generator 🔥 
  <a style="color: #EA005E; text-decoration: underline; font-size: 28px;" href="https://github.com/freddie-nelson/username-generators/stargazers">Become a Stargazer</a>
</h1>

**Generate random usernames based on your own custom templates and rules!**

## Installation

```bash
# with npm
npm install username-generator
```

```bash
# with yarn
yarn add username-generator
```

## Usage

```javascript
import { generateUsername } from "username-generator";

generateUsername("{{firstname:m}}_{{lastname}}"); // "john_smith"
```

## Templates

A template is a string that can contain any number of placeholders. Placeholders are replaced with a random value when generating a username. You can use placeholders multiple times in a template, each placeholder will be replaced with a different value.

You can also place your own text in the string, this text will be included in the generated username.

The following placeholders are available:

-   `{{adj}}` - A random adjective.
-   `{{noun}}` - A random noun.
-   `{{firstname:gender}}` - A random first name. gender can be `m`, `f` or `all`.
-   `{{lastname}}` - A random last name.
-   `{{number:min:max}}` - A random number between `min` and `max`.
-   `{{title:gender}}` - A random title. gender can be `m`, `f` or `all`.
-   `{{prefix}}` - A random prefix.

An example template could be `"{{adj}}{{noun}}{{number:100:999}}"`.

This template would generate a username like `bluecat123`.

Additionally any placeholder can be capitalized by adding a `^` before the placeholder name, or made uppercase by adding `^^` before the placeholder name.

For example, `{{^adj}}` would generate a username like `Bluecat123`, and `{{^^adj}}` would generate a username like `BLUEcat123`.

## Contributing

### Prerequisites

-   node (lts version)
-   yarn (1.^22.10)

### Setup

```bash
# clone repo
git clone https://github.com/freddie-nelson/username-generator
cd username-generator

# install dependencies
yarn

# start dev server
yarn dev

# run build
node dist/index.esm.js
```

## License

[MIT](https://opensource.org/licenses/MIT)

Copyright © 2020 - Present, Freddie Nelson

## Contact

-   [Send me an email 📧](mailto:freddie@freddienelson.co.uk)
-   [Contact me through my website](https://freddienelson.co.uk)

---
_Source: https://npm.io/package/better-username-generator · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
