Skip to content
Tesserae

Keyboard shortcuts

Focus search
/
This help dialog
?
Run the current tool
Ctrl/⌘ +Enter
Copy the output (when an output is focused)
Ctrl/⌘ +C

Shortcuts are ignored while you are typing in an input, a textarea or a select.

Developer Utilities

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.

On-device No network Offline-ready

🔒 100% Client-Side & Private — processed locally in your browser. Files never leave your device.

Try:

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.

See category