Skip to content
Marvin's Toolbox.

Search tools

Type to filter all tools

MongoDB ObjectId Decoder

Paste a MongoDB ObjectId and see the creation timestamp, the random value with its legacy machine and process id split, and the counter, color coded so each part of the ID maps to its meaning. Also generates ObjectIds for any date, handy for time-range queries.

Everything runs locally in your browser. Your data never leaves your device.

Bare hex or the ObjectId("…") form the mongo shell prints, either case.

Nothing decoded yet
Paste an ObjectId above, or try the example, to see the timestamp and counters it carries.

ObjectId for a date

Every ObjectId created at this second lies between the two values. For a time-range query, use each boundary date's first id, e.g. { _id: { $gte: ObjectId(start), $lt: ObjectId(end) } }.

Pick a date and time to get the matching boundary ids.

Generate an ObjectId

Generating…

TimestampRandom valueCounter

A fresh id for the current moment: the timestamp is now, the random value and counter come from the browser's crypto randomness.

About the MongoDB ObjectId Decoder Tool

This tool decodes MongoDB ObjectIds. Paste one, bare or in the ObjectId("…") form the mongo shell prints, and see when it was created, in UTC and your local time, along with its 5-byte random value, the legacy machine and process id split, and its counter. Each part is color coded from the hex characters through to the decoded fields.

It also works in reverse: pick any date to get the boundary ObjectIds for that second, ready for _id time-range queries, or generate a brand new ObjectId for the current moment.

What you can do

  • Get the creation date and time of a MongoDB ObjectId.
  • See which hex characters hold the timestamp, random value and counter.
  • Decode an ObjectId copied straight from the mongo shell, wrapper included.
  • Build the boundary ObjectIds for any date for _id time-range queries.
  • Generate a fresh ObjectId for the current time.
  • Copy ids as bare hex or in the ObjectId("…") shell form.

How to use the MongoDB ObjectId Decoder

  1. 1Paste the ObjectId. The wrapper, quotes and uppercase hex are all fine.
  2. 2Read the decoded fields: the creation timestamp, the random value and the counter.
  3. 3To query by date, pick a date and time in the ObjectId for a date section and copy a boundary id.

What the 12 bytes mean

An ObjectId is 12 bytes written as 24 hex characters. The first 4 bytes hold the creation time as whole seconds since the Unix epoch, which is why you can pull a created-at date out of any ObjectId even when the document stores no such field. The next 5 bytes are a random value chosen once per process. Older drivers built them from a 3-byte machine hash and a 2-byte process id, and the decoder shows that split too. The last 3 bytes are a counter that starts at a random value and increases with every id, so ids made by one process within one second still differ.

The timestamp only has second precision, and it runs out in February 2106 when the 4 bytes overflow. The counter wraps after 16,777,215 ids.

Time-range queries on the id

Because the timestamp leads, ObjectIds sort roughly by creation time and the _id index doubles as a created-at index. To find documents from a period, build the boundary id for the start and the end of the period and query with $gte and $lt. The generator here fills the random and counter bytes with zeros for the lower bound, which is exactly the id such a query needs.

Snowflake ids solve the same problem for Discord and Twitter, and the Snowflake ID Decoder takes those apart. The ULID Generator and UUID Decoder cover ULIDs and UUIDs.

Generate Nano IDs in bulk with full control over length and alphabet. Pick the default, hex, numbers-only or a custom character set, see the collision probability for your settings, and copy the results as a plain list.

Paste a Discord, Twitter or custom snowflake ID and see the exact creation timestamp, worker, process and sequence bits it carries. Pick a preset or set your own epoch and bit layout, or turn a date into the matching id range.

Generate ULIDs one at a time or in bulk: sortable, timestamp-prefixed identifiers in Crockford base32. Use monotonic mode for strictly ordered ids, decode any ULID back to its timestamp, and copy the results as a plain list.

Paste a UUID to see what it carries: version, variant, and for time-based versions the exact timestamp, clock sequence and node. Also shows the raw bytes, the 128-bit integer and the URN form.

Generate UUIDs in versions 1, 3, 4, 5, 6 and 7, one at a time or in bulk. Pick a version, set how many you need, and regenerate with one click. Name-based versions take a namespace and a name, and the result copies as a plain list.

Enter a resolution to get its simplified aspect ratio, or start from a ratio and one side to get the missing dimension. Knows the common ratios like 16:9, 4:3 and 21:9 and shows how close your size is to each.