MongoDB ObjectId
Split an ObjectId into the 4-byte creation timestamp, 5-byte per-process random value and 3-byte incrementing counter, or generate a fresh valid ObjectId from the current time.
🔒 100% Client-Side & Private — processed locally in your browser. Files never leave your device.
Options
Your result will appear here
Type or paste your input above, adjust the options, then press Run. Tip: press Ctrl+Enter to run, and ? for every shortcut.
How it works
The 12 bytes behind every ObjectId
A MongoDB ObjectId is 24 hexadecimal characters that decode to 12 bytes. In decode mode the tool splits them: the first four bytes are a big-endian Unix timestamp in seconds, the next five are a random value fixed per process, and the final three are an incrementing counter. You get the creation time as an ISO string and a Unix value, plus each section in hex and the counter in decimal.
Reading a creation time
The timestamp is the whole reason the format is useful for diagnostics: paste an _id from a document and you immediately know when that document was created, to the second, without a query. That is often enough to correlate a record with a deploy, a batch job or an incident window.
Generating a fresh id
Switch to generate mode and the tool builds a new, structurally valid ObjectId from the current second: the timestamp bytes come from the clock and the remaining bytes from crypto.getRandomValues. It has the same layout a driver would produce and a correct timestamp, but the random and counter bytes are freshly drawn rather than derived from a persistent per-process seed.
Validation and privacy
Decode requires exactly 24 characters and only 0-9 and a-f, and reports the length it got when that fails — so a truncated id copied out of a log is caught immediately. Nothing is looked up: both decode and generate run in the page with no database and no network, so an id from a private cluster stays on your device.
Questions
What do the 12 bytes mean?
Bytes 0-3 are a big-endian Unix timestamp in seconds, bytes 4-8 are a random value fixed per process, and bytes 9-11 are a counter that increments for each id.
Is the generated id the same as the MongoDB driver would make?
It has the same structure and a valid timestamp. The random and counter bytes come from crypto.getRandomValues rather than a persistent per-process seed.
What happens if I paste a truncated id?
Decode requires exactly 24 hex characters, so anything shorter or longer is refused with the length it received — handy for catching an id cut short when copied from a log.
Related tools
See categorySnowflake ID Decoder
Decode a 64-bit Snowflake ID into its timestamp, worker, process and sequence parts.
UUID Generator
Generate RFC 4122 UUIDs (v4 random or v7 time-ordered) in bulk.
Namespaced UUID (v3 / v5)
Generate a deterministic name-based UUID (v5 SHA-1 or v3 MD5) from a namespace and name.
Unix Timestamp Converter
Convert Unix timestamps to dates and dates to every common timestamp format.