Hash ID generator — turn numbers into short Hashids and back

Enter one or more whole numbers and a salt, and the tool encodes them as a short Hashids string such as NkK9; switch to Decode to turn an ID back into its numbers.

Live demo · real result from this tool
Mode

Hash ID

NkK9

Hashids hides sequential IDs; it is reversible by anyone with the salt and is not encryption.

Processed on your device — nothing is uploaded.

How to use the hash ID generator

  1. Pick a Mode: Encode numbers or Decode an ID.
  2. In Numbers (comma-separated) or ID to decode, type one number, several numbers such as 1, 2, 3, or the ID to decode.
  3. Enter your Salt. The same salt must be used for encoding and decoding.
  4. Optional: set a Minimum length (0 to 64) to pad short IDs, and change the Alphabet (at least 16 unique characters, no spaces).
  5. 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, salt this is my salt, gives NkK9. Decoding NkK9 with the same salt returns 12345.
  • Several numbers, no salt. 1, 2, 3 with an empty salt gives o2fXhV.
  • Padding. Number 1 with minimum length 8 gives gB0NV05e.
  • Wrong salt. Decoding NkK9 with the salt other gives “This ID does not decode with this salt, alphabet and minimum length.”
  • A short alphabet. Setting the alphabet to abc is 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?
No. Hashids only scrambles the order of the alphabet using your salt. Anyone who knows or guesses the salt can decode every ID, and the method is public. Use it to hide how many orders or users you have, not to protect data. Permission checks still belong on the server.
Will the IDs match my backend library?
The tool follows the hashids.js version 2 algorithm and reproduces its published reference values, such as 12345 with the salt "this is my salt" giving NkK9. Libraries in other languages that follow the same algorithm should agree when the salt, alphabet and minimum length are identical.
Why does decoding fail with "does not decode"?
The ID was made with a different salt, alphabet or minimum length, or it has a typo. The tool re-encodes the decoded numbers and only accepts the result if it matches your ID exactly, so a wrong setting never returns made-up numbers.
What numbers can it encode?
Whole numbers from 0 up to 9,007,199,254,740,991, the largest integer JavaScript stores exactly. Negative numbers and decimals are refused.
Is this the same as an MD5 or SHA hash?
No. Despite the name, Hashids is reversible. A real hash, like the one from the SHA-256 hash generator, cannot be turned back into its input.

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close