PHPackages                             snortlin/nano-id - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. snortlin/nano-id

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

snortlin/nano-id
================

A tiny, secure, URL-friendly, unique string ID generator for PHP

1.0.1(10mo ago)420.9k↓30.3%1MITPHPPHP ^7.4|^8.0

Since May 3Pushed 10mo ago1 watchersCompare

[ Source](https://github.com/snortlin/nano-id)[ Packagist](https://packagist.org/packages/snortlin/nano-id)[ RSS](/packages/snortlin-nano-id/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)DependenciesVersions (3)Used By (1)

Nano ID
=======

[](#nano-id)

[![Nano ID logo by Anton Lovchikov](https://camo.githubusercontent.com/682f981e83617354735ab5431235d4b06580ad5fc9eb24baca0a8c04e5734697/68747470733a2f2f61692e6769746875622e696f2f6e616e6f69642f6c6f676f2e737667)](https://camo.githubusercontent.com/682f981e83617354735ab5431235d4b06580ad5fc9eb24baca0a8c04e5734697/68747470733a2f2f61692e6769746875622e696f2f6e616e6f69642f6c6f676f2e737667)

A tiny, secure, URL-friendly, unique string ID generator for PHP.

This package is PHP implementation of [ai's](https://github.com/ai) [nanoid](https://github.com/ai/nanoid). Read its documentation for more information.

- **Fast.** It is faster than UUID.
- **Safe.** It uses cryptographically strong random APIs. Can be used in clusters.
- **Compact.** It uses a larger alphabet than UUID (`A-Za-z0-9_-`). So ID size was reduced from 36 to 21 symbols.
- **Customizable.** Size, alphabet and Random Bytes Generator may be overridden.

Installation
------------

[](#installation)

The preferred method of installation is via [Composer](https://getcomposer.org/):

```
composer require snortlin/nano-id
```

Usage
-----

[](#usage)

### Base usage

[](#base-usage)

```
use Snortlin\NanoId\NanoId;

$nanoId = NanoId::nanoId(); // "unQ87dO06B5B-Ybq2Aum5"

// Custom size, default = 21
$nanoId = NanoId::nanoId(16); // "6PUg-8nn5IQrvKNw"

// Custom size and alphabet
$nanoId = NanoId::nanoId(16, '0123456789abcdef'); // "58b141975c2b72f3"
```

### Custom alphabet

[](#custom-alphabet)

```
use Snortlin\NanoId\NanoId;

// Default size (21), numbers (0123456789)
$nanoId = NanoId::nanoId(NanoId::SIZE_DEFAULT, NanoId::ALPHABET_NUMBERS); // "782295634533276321176"

// Custom size, numbers and English alphabet without unreadable letters: 1, l, I, 0, O, o, u, v, 5, S, s, 2, Z
$nanoId = NanoId::nanoId(12, NanoId::ALPHABET_ALPHA_NUMERIC_READABLE); // "AcFQM9X3pCi8"
```

### Faster and Non-Secure

[](#faster-and-non-secure)

By default, Nano ID uses random bytes generation for security and low collision probability. If you are not so concerned with security and more concerned with performance, you can use the faster non-secure generator.

```
use Snortlin\NanoId\NanoId;

$nanoId = NanoId::nanoIdNonSecure();

// Custom size, default = 21
$nanoId = NanoId::nanoIdNonSecure(16);

// Custom size and alphabet
$nanoId = NanoId::nanoIdNonSecure(16, '0123456789abcdef');
```

Tools
-----

[](#tools)

- [ID size calculator](https://github.com/CyberAP/nanoid-dictionary) shows collision probability when adjusting the ID alphabet or size.

Credits
-------

[](#credits)

- Andrey Sitnik [ai](https://github.com/ai) for [Nano ID](https://github.com/ai/nanoid).
- Stanislav Lashmanov [CyberAP](https://github.com/CyberAP) for [Predefined character sets to use with Nano ID](https://github.com/CyberAP/nanoid-dictionary).

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance53

Moderate activity, may be stable

Popularity31

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 57.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1513 days

Total

2

Last Release

328d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9af5cb9ca24e0eb3598369e199ab5ed10f1053f929da7d868da5f9fcb286d6af?d=identicon)[snortlin](/maintainers/snortlin)

---

Top Contributors

[![snortlin](https://avatars.githubusercontent.com/u/68695718?v=4)](https://github.com/snortlin "snortlin (4 commits)")[![leixner-qcm](https://avatars.githubusercontent.com/u/81631795?v=4)](https://github.com/leixner-qcm "leixner-qcm (3 commits)")

### Embed Badge

![Health badge](/badges/snortlin-nano-id/health.svg)

```
[![Health](https://phpackages.com/badges/snortlin-nano-id/health.svg)](https://phpackages.com/packages/snortlin-nano-id)
```

###  Alternatives

[prestashop/gsitemap

PrestaShop module gsitemap

607.5M2](/packages/prestashop-gsitemap)[crell/tukio

A robust, stand-alone PSR-14 event dispatcher implementation.

112183.8k13](/packages/crell-tukio)[phpmentors/domain-kata

Kata for domain models

73426.9k9](/packages/phpmentors-domain-kata)[yaza/laravel-repository-service

Simple repository, service pattern for laravel

14337.9k2](/packages/yaza-laravel-repository-service)[jjs/geonames-bundle

GeoNames.org geographical data and associated functionality

191.2k](/packages/jjs-geonames-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
