MongoDB ObjectId Converter
Every default MongoDB _id already records when the document was created, so you can often answer "when did this arrive?" without a createdAt field. Paste ObjectIds in any common form: 24 hex digits, ObjectId("..."), the extended JSON { "$oid": "..." } from an export, or 16 Base64 characters from a driver or log. The tool splits the 12 bytes into the 4-byte timestamp, the 5-byte random value and the 3-byte counter, shows the time in UTC, as a Unix timestamp and in your time zone, and summarizes how many processes a batch of IDs came from. It also works in reverse. Enter a date or Unix timestamp and you get the lowest and highest ObjectId possible in that second, plus a mongosh find() with $gte and $lt on _id, which lets you pull a time range using the _id index. Past January 2038 the top bit of the timestamp is set, and drivers and the server disagree on the date: mongosh reads it as unsigned, while $toDate on the server reads it as signed and returns a date between 1901 and 1969. The tool shows both. Decoding was compared with getTimestamp() and $toDate on MongoDB 7.0.43 for 3,004 ObjectIds, and date conversion with ObjectId.createFromTime(). Everything runs in your browser, so no IDs are uploaded.
Do more than mongodb objectid converter — meet Chat2DB
Chat2DB is an AI-powered SQL client for Windows, macOS and Linux. Write SQL in natural language, format and optimize queries automatically, and manage MySQL, PostgreSQL, Oracle and 20+ other databases in one workspace.
How to use
- Paste ObjectIds, dates or Unix timestamps, one per line, or click Generate for fresh ObjectIds.
- Enter the collection name used in the generated query, then click Convert.
- Read the decoded timestamp, random value and counter, or copy the _id range query. With two dates, the query covers the range between them.
Frequently asked questions
How do I get the timestamp from a MongoDB ObjectId?
The first 4 bytes (8 hex digits) are the creation time in seconds since the Unix epoch. In mongosh, run ObjectId("507f1f77bcf86cd799439011").getTimestamp(), which returns 2012-10-17T21:13:27.000Z. In an aggregation, use { $toDate: "$_id" }. By hand, 507f1f77 in hex is 1350508407 in decimal. The precision is one second and the clock is that of the machine that created the ID, which is usually the application server rather than the database. Pasting the ID into this tool gives the same result without a connection.
How do I query MongoDB documents by date using _id?
Build an ObjectId from the date and compare _id to it. Because the timestamp fills the first 4 bytes, ObjectIds sort by creation second, so db.orders.find({ _id: { $gte: ObjectId("6ae924000000000000000000") } }) returns documents created from 2026-11-03T00:00:00Z on, using the _id index. In mongosh, ObjectId.createFromTime(seconds) builds the bound for you. Use it only for collections whose _id values are generated at insert time. It fails for imported documents that kept old IDs, and within one second the order is not guaranteed across processes.
Is a MongoDB ObjectId unique and safe to expose?
ObjectIds are designed to be unique without coordination: the timestamp, the per-process random value and an incrementing counter make a collision very unlikely. They are not secret. Anyone who sees one can read when it was created, and later IDs from the same process can be guessed by incrementing the counter, so never use an ObjectId as an access token. Uniqueness in a collection comes from the unique index on _id, not from the value itself. To browse collections and test these _id queries in a GUI, try Chat2DB: download it at chat2db.ai/download or open app.chat2db.ai.
