ObjectId Generator

Generate ObjectIds and decode their timestamps

Runs in your browserUtility04Generators

What is ObjectId Generator?

A MongoDB ObjectId is a 24-character hexadecimal identifier made up of a 4-byte timestamp followed by 8 bytes of random data. This tool generates ObjectIds in bulk and also works in reverse, extracting the creation time from any ObjectId you paste in. Both directions run locally in your browser.

How to use ObjectId Generator

  1. 1Set how many ObjectIds to generate, then generate them.
  2. 2Paste an existing ObjectId on the right to decode its creation time.
  3. 3Copy the results for test fixtures or query filters.

Frequently asked questions

Can you get the creation time out of a MongoDB ObjectId?+

Yes. The first 4 bytes are a Unix timestamp in seconds, so you can tell roughly when a document was created without a separate createdAt field, and you can even filter by time range by comparing ObjectIds. The trade-off is that the ID leaks its creation time, which is worth weighing before exposing it publicly.

Is it safe to generate ObjectIds on the client?+

ObjectIds are designed to be generated client-side — the official drivers do exactly that, which is how you can know a document's ID before inserting it. Just remember that only about 64 bits are random, so an ObjectId is not suitable as an unguessable credential.

Related tools

All tools