MongoDB ObjectId Decoder & Generator
Read ObjectId creation times, inspect opaque random bytes and counters, generate test IDs, and build second-based query boundaries.
The 12-byte format
Modern BSON ObjectIds contain a 4-byte unsigned big-endian Unix-seconds timestamp, 5 opaque random bytes and a 3-byte counter. The middle bytes are not a reliable machine name or process ID. The timestamp ranges from 1970-01-01 to 2106-02-07T06:28:15Z and has second precision.
Parse, generate and compose
Decode accepts exactly 24 hexadecimal characters or an ObjectId("…") shell wrapper, up to 1,000 lines. Generation uses Web Crypto for a fresh 5-byte batch random value and a random initial counter, then increments the counter within the batch. Composition lets you specify the random bytes and counter for reproducible fixtures.
Query boundaries are not unique IDs
Boundary mode fixes the first four bytes to the selected second and returns the all-zero and all-FF suffixes. Use them as inclusive lower and upper bounds for that second, not as new document IDs. Fractional milliseconds are floored to seconds. Neither an ObjectId nor its timestamp proves ownership or the actual creation time of a record.
Reference
Questions & answers
Does a decoded time prove when a record was created?
No. IDs can be composed or assigned elsewhere. A decoded timestamp is only the time stored in this particular format.
Are inputs uploaded or saved?
No. The tool runs locally in a Web Worker and does not send IDs to an API or save them in local storage. Copy and Download use the current result; edits or cancellation discard stale output.