PHPackages                             sqids/sqids - 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. sqids/sqids

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

sqids/sqids
===========

Generate short YouTube-looking IDs from numbers

0.5.0(1y ago)6041.6M↓13.2%17[1 issues](https://github.com/sqids/sqids-php/issues)20MITPHPPHP ^8.1CI passing

Since Jul 29Pushed 3mo ago8 watchersCompare

[ Source](https://github.com/sqids/sqids-php)[ Packagist](https://packagist.org/packages/sqids/sqids)[ Docs](https://sqids.org/php)[ RSS](/packages/sqids-sqids/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (1)Versions (10)Used By (20)

[Sqids PHP](https://sqids.org/php)
==================================

[](#sqids-php)

[![Build Status](https://camo.githubusercontent.com/02c9f08b8f57032e36c98994f8ed75ff8f2e5aafc9ed058eab2575f2235e7a8e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f73716964732f73716964732d7068702f706870756e69742e796d6c3f6c6162656c3d7465737473)](https://github.com/sqids/sqids/actions)[![Monthly Downloads](https://camo.githubusercontent.com/cd5c874bef1cf26ce4650c70ea741e38e53bab50ac0567ac87345d541a522aa0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f73716964732f7371696473)](https://packagist.org/packages/sqids/sqids/stats)[![Latest Version](https://camo.githubusercontent.com/1368c630c3ad58deed0d8f32cf85067d0dce936959917dc81069e236527f1d4e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73716964732f7371696473)](https://packagist.org/packages/sqids/sqids)

[Sqids](https://sqids.org/php) (*pronounced "squids"*) is a small library that lets you **generate unique IDs from numbers**. It's good for link shortening, fast &amp; URL-safe ID generation and decoding back into numbers for quicker database lookups.

Features:

- **Encode multiple numbers** - generate short IDs from one or several non-negative numbers
- **Quick decoding** - easily decode IDs back into numbers
- **Unique IDs** - generate unique IDs by shuffling the alphabet once
- **ID padding** - provide minimum length to make IDs more uniform
- **URL safe** - auto-generated IDs do not contain common profanity
- **Randomized output** - Sequential input provides nonconsecutive IDs
- **Many implementations** - Support for [40+ programming languages](https://sqids.org/)

🧰 Use-cases
-----------

[](#-use-cases)

Good for:

- Generating IDs for public URLs (eg: link shortening)
- Generating IDs for internal systems (eg: event tracking)
- Decoding for quicker database lookups (eg: by primary keys)

Not good for:

- Sensitive data (this is not an encryption library)
- User IDs (can be decoded revealing user count)

🚀 Getting started
-----------------

[](#-getting-started)

Require this package, with [Composer](https://getcomposer.org), in the root directory of your project.

```
composer require sqids/sqids
```

Then you can import the class into your application:

```
use Sqids\Sqids;
$sqids = new Sqids();
```

Important

Sqids require either the [`bcmath`](https://secure.php.net/manual/en/book.bc.php) or [`gmp`](https://secure.php.net/manual/en/book.gmp.php) extension in order to work.

👩‍💻 Examples
------------

[](#‍-examples)

Simple encode &amp; decode:

```
$sqids = new Sqids();
$id = $sqids->encode([1, 2, 3]); // "86Rf07"
$numbers = $sqids->decode($id); // [1, 2, 3]
```

Note

🚧 Because of the algorithm's design, **multiple IDs can decode back into the same sequence of numbers**. If it's important to your design that IDs are canonical, you have to manually re-encode decoded numbers and check that the generated ID matches.

Enforce a *minimum* length for IDs:

```
$sqids = new Sqids(minLength: 10);
$id = $sqids->encode([1, 2, 3]); // "86Rf07xd4z"
$numbers = $sqids->decode($id); // [1, 2, 3]
```

Randomize IDs by providing a custom alphabet:

```
$sqids = new Sqids(alphabet: 'FxnXM1kBN6cuhsAvjW3Co7l2RePyY8DwaU04Tzt9fHQrqSVKdpimLGIJOgb5ZE');
$id = $sqids->encode([1, 2, 3]); // "B4aajs"
$numbers = $sqids->decode($id); // [1, 2, 3]
```

Prevent specific words from appearing anywhere in the auto-generated IDs:

```
$sqids = new Sqids(blocklist: ['86Rf07']);
$id = $sqids->encode([1, 2, 3]); // "se8ojk"
$numbers = $sqids->decode($id); // [1, 2, 3]
```

📝 License
---------

[](#-license)

[MIT](LICENSE)

###  Health Score

53

—

FairBetter than 96% of packages

Maintenance63

Regular maintenance activity

Popularity61

Solid adoption and visibility

Community32

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 52.2% 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 ~75 days

Recently: every ~128 days

Total

8

Last Release

520d ago

PHP version history (2 changes)0.0.1PHP ^8.2

0.4.1PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/63e77154439395019fb74adc3d1402bbba09ab726c74e2448968a1174c6a4415?d=identicon)[vinkla](/maintainers/vinkla)

![](https://www.gravatar.com/avatar/b828fac261e5ae3345f4b71a86a65e44091a4b40e7c8b3ec5fb7f1d73d5a4230?d=identicon)[4kimov](/maintainers/4kimov)

---

Top Contributors

[![vinkla](https://avatars.githubusercontent.com/u/499192?v=4)](https://github.com/vinkla "vinkla (35 commits)")[![4kimov](https://avatars.githubusercontent.com/u/56128128?v=4)](https://github.com/4kimov "4kimov (24 commits)")[![GromNaN](https://avatars.githubusercontent.com/u/400034?v=4)](https://github.com/GromNaN "GromNaN (8 commits)")

---

Tags

hashidsidid-generatorphpphp-libraryphp8short-idshort-urlsqidsuidunique-idunique-id-generatorencodedecodeidshashidsgeneratesqids

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/sqids-sqids/health.svg)

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

###  Alternatives

[hashids/hashids

Generate short, unique, non-sequential ids (like YouTube and Bitly) from numbers

5.5k50.9M302](/packages/hashids-hashids)[jenssegers/optimus

Id obfuscation based on Knuth's integer hash method

1.3k4.9M32](/packages/jenssegers-optimus)[christian-riesen/base32

Base32 encoder/decoder according to RFC 4648

13433.2M69](/packages/christian-riesen-base32)[delight-im/ids

Short, obfuscated and efficient IDs for PHP

289.9k1](/packages/delight-im-ids)[torann/hashids

Laravel package for Hashids

54341.1k](/packages/torann-hashids)[skleeschulte/base32

Base32 encoding and decoding class (RFC 4648, RFC 4648 extended hex, Crockford, z-base-32/Zooko).

17320.5k9](/packages/skleeschulte-base32)

PHPackages © 2026

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