← All Tools

MongoDB ObjectID Decoder — Extract Timestamp from ObjectID

Decode any MongoDB ObjectID to extract its embedded creation timestamp, random bytes, and counter. See exactly when a document was created without a separate createdAt field. Also generates new ObjectIDs.

Free, no sign-up — one of the SaaSQuickStart Developer tools.

Frequently asked questions

Can I range-query by creation date without a timestamp field?

Yes. Because the first 4 bytes of every ObjectID are a timestamp, you can query _id with $gt/$lt using ObjectIDs constructed from known timestamps. This is exactly how the snippet above works.

Are ObjectIDs globally unique across collections?

They are generated to be globally unique across a distributed system, but MongoDB does not enforce uniqueness across different collections — only within the _id index of a single collection.

The generated ObjectID above looks real — is it valid?

The timestamp part is real (current time). The random and counter parts are generated in the browser using crypto.getRandomValues(), which is cryptographically secure. The result is a valid ObjectID that MongoDB would accept.

All free tools · SaaSQuickStart