An extremely fast unique ID generator for JavaScript and TypeScript, with optional sorting/timestamping.
See the codeAn extremely fast unique ID generator for JavaScript and TypeScript, with optional sorting/timestamping.
import jetId from 'jet-id';
jetId(); // '9Q8SWWBTY-7NVXM-FT9S6-XB4R3M'
Every ID is 25 random characters from the Crockford base32 alphabet, split into groups of 9-5-5-6.
Main features
nanoid(). See benchmarks.Other perks
jetId() and jetId.test/jetId.timed/jetId.parseTimed.npm install jet-id
Just call the default import, there are no options to pass:
import jetId from 'jet-id';
jetId(); // '9Q8SWWBTY-7NVXM-FT9S6-XB4R3M'
jetId contains a .test function if you need to validate an ID. Note that .test is not case-sensitive.
const someId = 'avz6yg1rb-47j6r-xgns9-tqw29a';
console.log(jetId.test(someId)); // => true
jetId.timed(epoch?: number): string encodes the current time in the first nine characters, so IDs created later sort after ones created earlier.
You can pass your own timestamp in milliseconds; otherwise it defaults to Date.now():
// Default, uses Date.now()
jetId.timed(); // '1KKNTQ2CN-606ZG-8VF48-76B6F3'
// Custom timestamp
const date = new Date(2015, 5, 3);
const timedId = jetId.timed(date.getTime());
logger.info(timedId); // "19PW3GCC0..."
If an id has been timestamped, you can extract the epoch with jetId.parseTimed(id: string): number. This will use the validation function above so parsing is not case-sensitive.
// Parse timed id
const parsedId = jetId.parseTimed(timedId);
const dateStr = new Date(parsedId).toLocaleString();
logger.info(dateStr); // "6/3/2015 ..."
| Flag | Short | What it does |
|---|---|---|
--count <n> | -c | How many IDs to print. Defaults to 1. |
--timed | -t | Encode the current epoch in the first 9 characters, so the IDs sort by creation time. |
--help | -h | Show usage. |
--version | -v | Show the installed version. |
Node v24.13.0; V8 13.6.233.17-node.37; darwin/arm64; Apple M4 Pro
Median of 7 samples, at least 500 ms each, after a 500 ms warmup per generator.
| Generator | Characters | Random bits | Median ops/sec | ns/ID | Relative throughput |
|---|---|---|---|---|---|
| jetId() | 28 | 125 | 83,503,288 | 12.0 | 1.00x |
| nanoid() | 21 | 126 | 52,415,897 | 19.1 | 0.63x |
| Nano ID: Crockford, 25 chars | 25 | 125 | 47,073,761 | 21.2 | 0.56x |
| Nano ID: Crockford, 9-5-5-6 | 28 | 125 | 14,441,127 | 69.2 | 0.17x |
| uuid v4() | 36 | 122 | 8,536,998 | 117.1 | 0.10x |
| crypto.randomUUID() | 36 | 122 | 9,938,321 | 100.6 | 0.12x |
MIT © seanpmaxwell
13 commits
TypeScript
100.0%
An extremely fast unique ID generator for JavaScript and TypeScript, with optional sorting/timestamping.
See the codeAn extremely fast unique ID generator for JavaScript and TypeScript, with optional sorting/timestamping.
import jetId from 'jet-id';
jetId(); // '9Q8SWWBTY-7NVXM-FT9S6-XB4R3M'
Every ID is 25 random characters from the Crockford base32 alphabet, split into groups of 9-5-5-6.
Main features
nanoid(). See benchmarks.Other perks
jetId() and jetId.test/jetId.timed/jetId.parseTimed.npm install jet-id
Just call the default import, there are no options to pass:
import jetId from 'jet-id';
jetId(); // '9Q8SWWBTY-7NVXM-FT9S6-XB4R3M'
jetId contains a .test function if you need to validate an ID. Note that .test is not case-sensitive.
const someId = 'avz6yg1rb-47j6r-xgns9-tqw29a';
console.log(jetId.test(someId)); // => true
jetId.timed(epoch?: number): string encodes the current time in the first nine characters, so IDs created later sort after ones created earlier.
You can pass your own timestamp in milliseconds; otherwise it defaults to Date.now():
// Default, uses Date.now()
jetId.timed(); // '1KKNTQ2CN-606ZG-8VF48-76B6F3'
// Custom timestamp
const date = new Date(2015, 5, 3);
const timedId = jetId.timed(date.getTime());
logger.info(timedId); // "19PW3GCC0..."
If an id has been timestamped, you can extract the epoch with jetId.parseTimed(id: string): number. This will use the validation function above so parsing is not case-sensitive.
// Parse timed id
const parsedId = jetId.parseTimed(timedId);
const dateStr = new Date(parsedId).toLocaleString();
logger.info(dateStr); // "6/3/2015 ..."
| Flag | Short | What it does |
|---|---|---|
--count <n> | -c | How many IDs to print. Defaults to 1. |
--timed | -t | Encode the current epoch in the first 9 characters, so the IDs sort by creation time. |
--help | -h | Show usage. |
--version | -v | Show the installed version. |
Node v24.13.0; V8 13.6.233.17-node.37; darwin/arm64; Apple M4 Pro
Median of 7 samples, at least 500 ms each, after a 500 ms warmup per generator.
| Generator | Characters | Random bits | Median ops/sec | ns/ID | Relative throughput |
|---|---|---|---|---|---|
| jetId() | 28 | 125 | 83,503,288 | 12.0 | 1.00x |
| nanoid() | 21 | 126 | 52,415,897 | 19.1 | 0.63x |
| Nano ID: Crockford, 25 chars | 25 | 125 | 47,073,761 | 21.2 | 0.56x |
| Nano ID: Crockford, 9-5-5-6 | 28 | 125 | 14,441,127 | 69.2 | 0.17x |
| uuid v4() | 36 | 122 | 8,536,998 | 117.1 | 0.10x |
| crypto.randomUUID() | 36 | 122 | 9,938,321 | 100.6 | 0.12x |
MIT © seanpmaxwell
13 commits
TypeScript
100.0%