How to use the ObjectId generator
- Leave Mode on Generate.
- Leave Timestamp (blank = now, UTC) empty for the current time, or pick a date and time. It is read as UTC.
- Set How many ObjectIds (up to 1,000) and press Generate.
- To read an ID, switch Mode to Read the timestamp, paste the ObjectId, and read Created (UTC) and Unix seconds.
What it does and when to use it
MongoDB gives every document an _id, and by default it is an ObjectId. Developers need them outside the database too: in JSON fixtures, seed scripts, mock API responses, and when writing references between collections by hand. This page makes IDs in the exact format, so drivers and validation accept them.
Setting the timestamp is the useful extra. Because the time sits at the front, ObjectIds sort roughly by creation time, and a hand-made ObjectId for a given moment works as a cut-off in queries. The decoder answers the common support question “when was this record created?” straight from the ID.
For time-sortable IDs outside MongoDB, see the ULID generator or version 7 in the UUID generator. To turn Unix seconds into a readable date in other formats, use the Unix timestamp converter.
How it works
The tool writes the chosen time as 8 hex digits of Unix seconds. It then draws a 5-byte random value and a random starting counter with crypto.getRandomValues, once per batch, which is how MongoDB drivers behave within one process. Each ID adds one to the counter, so a batch is in strict order. Decoding reads the first 8 hex digits back as seconds.
Worked examples
- MongoDB’s documentation example.
507f1f77bcf86cd799439011decodes toCreated (UTC): 2012-10-17T21:13:27.000ZandUnix seconds: 1350508407. - Pasted from the shell.
ObjectId("507f1f77bcf86cd799439011")gives the same answer. - A fixed start of year. Timestamp 2026-01-01 00:00 makes IDs that all begin
6955b900, for example6955b900abb9973ea0695889and6955b900abb9973ea069588a. The last digits count up. - Not an ObjectId.
xyzreturns “An ObjectId is 24 hexadecimal characters.”
Limits and tips
- Precision is one second. IDs made in the same second sort by counter, not by real order across machines.
- The 4-byte time field runs out in the year 2106.
- The tool does not check whether an ID already exists in your database.
Frequently asked questions
What is inside an ObjectId?
Why would I want an ObjectId with a past or future time?
Can I paste an ObjectId with the ObjectId(...) wrapper?
Are ObjectIds secret or unguessable?
How do we know nothing is uploaded? Test it yourself on the privacy proof page.