Sqids Decoder
Decode a Sqids identifier made with the standard alphabet into its original sequence of nonnegative integers.
Description
Decode a standard Sqids identifier into its original sequence of nonnegative integers.
Sqids decoding reverses the alphabet transformations made by the matching encoder. It requires the same alphabet configuration but does not need the blocklist, because the blocklist only changes which identifiers the encoder chooses to emit.1
When to use Sqids Decoder
Use the decoder for route parameters, presentation IDs, or stored Sqids values created with the standard configuration when the underlying integer sequence is needed.
How Sqids Decoder works
The first character selects the alphabet offset. The decoder reconstructs the shuffled alphabet, splits the remaining identifier at derived separators, and converts each segment from that alphabet back into a nonnegative integer.1
How the Sqids decoding function processes input
- Verify that the identifier uses characters from the configured alphabet.
- Derive the same shuffled alphabet and separators from the leading character.
- Split the identifier into one segment per encoded number.
- Convert each segment from the shuffled base to a nonnegative integer.
Limitations and assumptions
- Decoding does not prove that an identifier was issued by your application.
- The wrong custom alphabet can fail or yield a different interpretation.
- Sqids values are not encrypted or authenticated and should be checked against application authorization rules.
Alternative or Complementary approaches
Use the matching encoder to create identifiers. Use signed tokens, opaque random IDs, or UUIDs when reversibility or integer disclosure is undesirable.
References
-
Sqids specification — Sqids
Similar or alternative tools
- Sqids Encoder
Encode nonnegative integers into a short ID.
- Base58 Decoder
Decode Base58 text into its represented bytes.
- UUID Parser
Inspect a UUID-style identifier.