Developer Tools
MongoDB ObjectId Decoder
Decode MongoDB ObjectIds to a timestamp in your browser. Read the date, machine, process, and counter bytes, and build ObjectIds from a date.
MongoDB ObjectId decoder
Layout
Default in every MongoDB driver since the BSON specification update of September 2012. Used by mongosh, the Node.js, Python (PyMongo), Go, Java, .NET, Ruby, Rust, and Swift drivers, by MongoDB Atlas, by Realm, and by Compass.
Paste one ObjectId to see the embedded timestamp and the per-field byte breakdown.
Accepts a bare 24-character hex string, an ObjectId("...") wrapper from mongosh or Robo3T, or a {"$oid": "..."} extended JSON wrapper from a Compass or mongoexport file.
Decoded timestamp
2012-10-17T21:13:27.000Z
13 years ago
Details
- Hex
- 507f1f77bcf86cd799439011
- mongosh form
- ObjectId("507f1f77bcf86cd799439011")
- Extended JSON
- {"$oid": "507f1f77bcf86cd799439011"}
- Unix seconds
- 1350508407
- Unix ms
- 1350508407000
- ISO UTC
- 2012-10-17T21:13:27.000Z
- Timestamp (4B)
- 0x507f1f77decimal 1350508407
- Random value (5B)
- 0xbcf86cd799decimal 811621734297
Generated once per process. The same process emits the same 5 bytes for the lifetime of the connection.
- Counter (3B)
- 0x439011decimal 4427793
Starts at a random initial value and increments once per ObjectId generated within the same process.
12-byte layout
What is a MongoDB ObjectId?
An ObjectId is a 12-byte value that the MongoDB driver assigns to a new document as its _id when the application does not supply one. The first four bytes hold a 32-bit big-endian Unix timestamp in seconds, so two ObjectIds generated near each other in time also compare near each other as numbers. That is what makes _id useful for range queries by creation time, and why MongoDB documents are loosely ordered on disk without any extra timestamp column.
Decoding rules used here
- Input is normalized into a 24-character lowercase hex string after stripping any ObjectId(...), {"$oid": ...}, surrounding quotes, whitespace, dashes, and underscores.
- The first 4 bytes are read big-endian as a 32-bit unsigned integer. That integer is the timestamp in seconds since the Unix epoch (1970-01-01 UTC).
- The remaining 8 bytes are split according to the chosen layout (v4+ random plus counter, or v3 machine plus process plus counter).
- Two-byte fields are shown in both big-endian and little-endian decimal because legacy drivers disagreed on the byte order.
- All math runs locally with native bit operations; the ObjectIds you paste here never leave your browser.
Layout reference
| Layout | Bytes 0-3 | Bytes 4-8 | Bytes 9-11 |
|---|---|---|---|
| v4+ (modern) | 32-bit timestamp (big-endian seconds) | 5-byte random value (per process) | 3-byte counter |
| v3 / legacy (pre-2012) | 32-bit timestamp (big-endian seconds) | 3-byte machine ID, then 2-byte process ID | 3-byte counter |
The canonical sample ObjectId 507f1f77bcf86cd799439011 appears throughout the official MongoDB documentation and decodes to 2012-10-17T20:46:47Z under either layout.
How to use
- Pick a layout: v4+ (default for every modern MongoDB driver) or v3 legacy for pre-2012 ObjectIds.
- Choose a mode at the top: Decode single for one ObjectId, Decode batch for a pasted list, Build from date to invert the process, or Generate random to mint a v4 ObjectId on the spot.
- Paste an ObjectId, paste a list of ObjectIds (one per line), or pick a date depending on the mode. Decoding runs on every keystroke and accepts ObjectId("...") and {"$oid": "..."} wrappers along with bare hex.
- Read the timestamp, hex, mongosh and extended JSON forms, and the per-field values in the result panel. Use the copy buttons to lift any value, or Copy results as CSV in batch mode.
- In Build from date mode, copy the produced ObjectId into a MongoDB query like _id: { $gt: ObjectId("...") } to fetch every document created after that moment without indexing a timestamp field.
About this tool
MongoDB ObjectId Decoder parses 12-byte MongoDB ObjectIds (also called BSON ObjectIds) and shows the embedded creation timestamp, the machine, process, random, and counter bytes, and every common wrapper form a developer is likely to encounter. Paste a bare 24-character hex string, an ObjectId("...") wrapper from mongosh, Robo3T, NoSQLBooster, or Studio 3T, or a {"$oid": "..."} extended JSON wrapper from a Compass export or a mongoexport file, and the tool strips the wrapper, normalizes the value to lowercase hex, and walks the bytes one field at a time. The default v4+ layout reflects the BSON specification update of September 2012 used by every modern driver (Node.js, PyMongo, Go, Java, .NET, Ruby, Rust, Swift) and by mongosh, Compass, Atlas, and Realm: bytes 0-3 are a big-endian 32-bit Unix timestamp in seconds, bytes 4-8 are a 5-byte random value chosen once per process, and bytes 9-11 are a 3-byte counter that starts at a random initial value and increments on each ObjectId. The v3 legacy layout still appears in archived databases and older tutorials and splits the middle bytes into a 3-byte machine identifier (the first 3 bytes of the MD5 hash of the host name) and a 2-byte process identifier; the process ID is shown in both big-endian and little-endian decimal because legacy drivers disagreed on the byte order. Each decoded ObjectId reports the canonical lowercase hex, the mongosh ObjectId(...) form, the extended JSON $oid form, the Unix seconds and milliseconds, an ISO 8601 UTC timestamp, a relative description (such as 3 years ago), every field decoded under the chosen layout with its hex bytes and decimal value, and a colour-coded 12-byte strip so you can see exactly which bytes became which field. A Batch mode decodes a pasted list of ObjectIds at once, counts how many parsed successfully, and exports the timestamps as CSV ready to drop into a spreadsheet or a query. A Build from date mode goes the other way: pick a calendar moment and the tool returns a representative ObjectId with the random and counter bytes zeroed, which is the standard recipe for the MongoDB range query db.collection.find({_id: {$gt: ObjectId("...")}}) that selects every document created after a given time without a separate index on a timestamp field. A Generate mode produces a fresh v4 ObjectId from the current second-precision Unix timestamp plus 8 bytes from the browser CSPRNG via crypto.getRandomValues, useful for test fixtures and seed data. Everything runs locally on your device, so the ObjectIds you paste here, along with any production identifiers they expose, never leave your browser.
Free to use. Works in your browser. No signup, no login.
Related tools
You may also like
Snowflake ID Decoder
Decode Discord, Twitter or X, and Instagram snowflake IDs to a date and field breakdown.
Open tool
GeneratorUUID v7 Generator
Time-ordered UUID v7 generator and version-aware UUID decoder.
Open tool
GeneratorULID Generator
Generate sortable ULID identifiers and decode any ULID back into its timestamp.
Open tool
Date & TimeUnix Timestamp Converter
Convert epoch timestamps to dates and back.
Open tool
DeveloperUUID Validator
Validate UUIDs, identify the version and variant, and decode v1, v6, and v7 timestamps.
Open tool
GeneratorUUID Generator
Generate UUID v4 identifiers in batch.
Open tool