YOUSUF OMER
Back to Blog
2025-12-21

Short Unique IDs in Dart with Sqids

#dart#sqids#opensource

What is Sqids?

Sqids (pronounced "squids") is an open-source library that lets you generate short unique identifiers from numbers. These IDs are URL-safe, can encode several numbers, and do not contain common profanity words.

This is what they look like:

Dart Implementation

Sqids Dart allows you to easily use Sqids in your Dart and Flutter projects.

Quick encode & decode example:

final sqids = Sqids()
const id = sqids.encode([1, 2, 3]) // "86Rf07"
const numbers = sqids.decode(id) // [1, 2, 3]

Custom Length

If IDs are too short, you can pad them to a certain length:

final sqids = Sqids({ minLength: 10, })
const id = sqids.encode([1, 2, 3]) // "86Rf07xd4z"
const numbers = sqids.decode(id) // [1, 2, 3]

Custom Alphabet

Create unique IDs by shuffling the alphabet:

final sqids = Sqids({ alphabet: 'k3G7QAe51FCsPW92uEOyq4Bg6Sp8YzVTmnU0liwDdHXLajZrfxNhobJIRcMvKt', })
const id = sqids.encode([1, 2, 3]) // "XRKUdQ"
const numbers = sqids.decode(id) // [1, 2, 3]

Use Cases

The main use of Sqids is purely visual. If you'd like to use IDs instead of numbers in your project, Sqids could be a good choice.

  • Link Shortening: Generate short, unique IDs for URLs.
  • Obfuscating IDs: Hide incremental database IDs from users.
  • Event IDs: Create friendly IDs for event tickets or reservations.

For full documentation, visit github.com/sqids/sqids-dart.