How to use the hash ID generator
- Pick a Mode: Encode numbers or Decode an ID.
- In Numbers (comma-separated) or ID to decode, type one number, several numbers such as
1, 2, 3, or the ID to decode. - Enter your Salt. The same salt must be used for encoding and decoding.
- Optional: set a Minimum length (0 to 64) to pad short IDs, and change the Alphabet (at least 16 unique characters, no spaces).
- Read the Hash ID, or the Numbers in decode mode.
What it does and when to use it
Many apps show database IDs in links, such as /invoice/1042. That tells everyone how many invoices exist and invites people to try /invoice/1043. Hashids replaces the number with a short string that looks random, such as /invoice/NkK9, and your server decodes it back to 1042 before the database lookup.
This page is handy for checking what your backend should produce, decoding an ID from a log or support ticket, or picking a minimum length that keeps URLs a steady size. If you need a random ID that does not come from a number at all, use the Nano ID generator or the UUID generator. For a one-way fingerprint of text, use the MD5 hash generator.
How it works
Hashids first splits the alphabet into working characters, separators and guard characters, then shuffles the working set with a fixed routine driven by the salt. Each number is written in that shuffled base (62 characters by default, minus separators and guards). A “lottery” character chosen from the numbers starts the ID, the alphabet is reshuffled before each number, and separators go between numbers. If the result is shorter than the minimum length, guard characters and more shuffled characters are added on both sides.
Decoding reverses those steps. The tool then encodes the numbers again and checks that the ID matches.
Worked examples
- The reference case. Number
12345, saltthis is my salt, givesNkK9. DecodingNkK9with the same salt returns12345. - Several numbers, no salt.
1, 2, 3with an empty salt giveso2fXhV. - Padding. Number
1with minimum length 8 givesgB0NV05e. - Wrong salt. Decoding
NkK9with the saltothergives “This ID does not decode with this salt, alphabet and minimum length.” - A short alphabet. Setting the alphabet to
abcis refused with “The alphabet needs at least 16 unique characters.”
Limits and tips
- Changing the salt later breaks every link you have shared. Choose it once and keep it in your config.
- The letters c, f, h, i, s, t and u (and their capitals) are set aside as separators between numbers, so the digits of each number are written without them.
- Hashids does not stop people guessing valid IDs. Always check access on the server.
Frequently asked questions
Is a Hashids string encrypted?
Will the IDs match my backend library?
Why does decoding fail with "does not decode"?
What numbers can it encode?
Is this the same as an MD5 or SHA hash?
How do we know nothing is uploaded? Test it yourself on the privacy proof page.