Convert a MongoDB ObjectId to timestamp and date
The first four bytes of every MongoDB ObjectId store the moment it was created, in seconds since the Unix epoch. This ObjectId to timestamp decoder reads those bytes and shows the creation date in UTC, so you can tell when a document was inserted even if the collection has no createdAt field.
Example
Input:
ObjectId("507f1f77bcf86cd799439011")
Output:
507f1f77bcf86cd799439011
Created: 2012-10-17T21:13:27.000Z
Unix time: 1350508407
Random: bcf86cd799 (per-process value)
Counter: 4427793 (0x439011)
Query: db.collection.find({ _id: { $gte: ObjectId("507f1f770000000000000000") } })
In the tool, the Created line also shows the relative age, for example "13.9 years ago".
What each field means
- Created / Unix time: hex digits 1–8 as seconds since 1970, shown as an ISO 8601 date.
- Random: digits 9–18, a 5-byte value chosen once per client process. IDs with the same random value were very likely created by the same application instance.
- Counter: the last 3 bytes, incremented for each new ID. Consecutive counters from the same process show the order of inserts within one second.
- Query: an ObjectId with the same timestamp and all other bytes set to zero. Using it with
$gte(or$lt) lets you filter documents by creation time using the always-indexed_idfield.
Flexible input
The decoder scans your text for any 24-character hexadecimal token, so you can paste shell output, Extended JSON like {"$oid": "65f1c0a2b3d4e5f6a7b8c9d0"}, an array of IDs from an API response or a chunk of a log file. Up to 500 IDs are decoded in one go. If nothing matches, you will see a message asking for 24 hex characters.
Things to keep in mind
- The timestamp is set by whoever generated the ID — usually the driver on the application server — so clock drift on that machine shows up here.
- IDs created by hand or with a custom time, for example by the ObjectId generator, can carry any date.
- Precision is one second. For millisecond-level IDs from other systems, try the Snowflake ID decoder or convert raw seconds with the Unix timestamp converter.
Privacy
Everything is decoded in your browser. The IDs you paste are not transmitted, so you can safely inspect IDs from production data.