>_devtools

MongoDB ObjectId Generator and Decoder

Generate MongoDB ObjectIds and decode the timestamp, random value, and counter from an existing one.

What this does

Generate MongoDB ObjectId values, or paste an existing one to read the time it was created. An ObjectId is 12 bytes written as 24 hex digits.

Layout

  • 4 bytes: creation time as Unix seconds, big-endian.
  • 5 bytes: a random value chosen once per process.
  • 3 bytes: a counter that starts at a random number and increments for each new ObjectId.

Because the time comes first, ObjectIds sort roughly by creation time. Precision is one second, so two ids made in the same second differ only in the counter.

Example

507f1f77bcf86cd799439011 decodes to 2012-10-17T21:13:27.000Z, random value bcf86cd799, and counter 4427793.

Notes

Generated ids follow the format but are not registered with any database. Use them for fixtures and tests; let your driver create ids for real documents.

Privacy

Everything runs in your browser. Nothing is uploaded or stored.