Mongo Object Id: generator / encoder / decoder
Calculator decodes (splits) your mongo object id into separated unix timestamp, random value and incrementing counter parts or encodes (generates) new mongo-id.

Beta version#

This online calculator is currently under heavy development. It may or it may NOT work correctly.
You CAN try to use it. You CAN even get the proper results.
However, please VERIFY all results on your own, as the level of completion of this item is NOT CONFIRMED.
Feel free to send any ideas and comments !

Mongo Object ID components: timestamp, random value and counter#

UNIX timestamp in seconds (4 bytes)
Timestamp as decimal number
Timestamp as hex number
Timestamp in ISO format2021-07-15T11:53:58.000Z
Set to now
Arbitrary random value (5 bytes)
Random value as decimal number
Random value as hex number
Generate new random
Incrementing counter (3 bytes)
Counter as decimal number
Counter as hex number

Final Mongo Object ID#

Full mongo object id as hexadecimal number (12 bytes)
Mongo Object ID as decimal number
Mongo Object ID as hex number
Generate all

More mongo object ids#


Some facts#

  • Mongo Object Id is a string that identifies an entry in the mongo database.
  • The mongo identifier is most often written as hexadecimal.
  • Mongo Object Id consists of a total of 12 bytes which makes 24 characters in hexadecimal.
  • The identifier is made of three parts:
    • UNIX timestamp in seconds (4 bytes, 8 hex characters),
    • arbitrary string (5 bytes, 10 hex characters),
    • incrementing counter (3 bytes, 6 hex characters).
  • An arbitrary 5-byte part can contain any random value. In practice, the way it is generated depends on the implementation. For example, some implementations use MD5 hash of process id (PID) and hostname of machine, where the id is created.
  • The counter also starts from random number and then is incremented for each locally created id.
    • It's 3 bytes counter, which loops after 16777216 objects. The max value is 16777215 or 0xffffff in hex.
    • The number 16777216 is the number of different values​ that can be stored in 3-byte counter (24 bits). It's equal to two raised to the twenty-fourth power (224).
  • There is no global mongo id database. The identifiers are generated locally.
  • Generating a new mongo identifier does not guarantee that it will be unique. The use of the identifier is based on the fact that a collision is unlikely. We can generate over 18 quintillions (264 = ~18.4×1018) of unique identifiers every second.

Tags and links to this website#

What tags this calculator has#


This is permalink. Permalink is the link containing your input data. Just copy it and share your work with friends:

Links to external sites (leaving Calculla?)#

JavaScript failed !
So this is static version of this website.
This website works a lot better in JavaScript enabled browser.
Please enable JavaScript.