MongoDB ObjectId Generator
Generate valid MongoDB ObjectIds and decode an ObjectId to reveal its embedded timestamp. Create one or many 24-character hex ids.
Last reviewed by the Radiatus Cloud team
Generate valid MongoDB ObjectIds, or decode one to reveal its creation time.
Need this built for your product?
We design, build & host secure software & APIs.
Generate and decode MongoDB ObjectIds
A MongoDB ObjectId is a twelve-byte identifier represented as twenty-four hexadecimal characters, used as the default primary key for documents. The first four bytes encode the creation time as a Unix timestamp, and the remaining bytes provide randomness and a counter so that ids are unique even when many are created at once. This tool generates valid ObjectIds with a current timestamp and random tail, and decodes any ObjectId to reveal the embedded creation time.
Because the timestamp sits at the front, ObjectIds sort roughly in creation order, which is a useful property when paging through recent documents.
Working with ObjectIds
Developers need sample ObjectIds for seeding test data, writing fixtures and crafting queries, and they often want to read the timestamp out of an existing id to see when a document was created without storing a separate date. This tool covers both tasks. Generating many at once is handy for bulk test data.
The ids produced here use a client-side random component rather than the exact machine and process identifiers of a real MongoDB driver, but they are valid twenty-four-character ObjectIds with correct timestamps and are suitable for testing. Decoding works on any genuine ObjectId. All processing happens locally in your browser.
Related tools
- JSON Formatter — Format and beautify JSON in your browser. Pinpoints syntax errors by line and column, flags unsafe integers, and never uploads your data to a server.
- JSON Validator — Validate JSON syntax with precise line and column errors, and check documents against a JSON Schema. Runs locally in your browser, nothing uploaded.
- Regex Tester — Test regular expressions against sample text with live match highlighting, capture groups and flag control. Runs entirely in your browser.
- HTML Minifier — Minify HTML by removing comments and redundant whitespace, without breaking inline elements or pre blocks. Runs entirely in your browser.
Frequently Asked Questions
What is a MongoDB ObjectId?
It is a twelve-byte unique identifier shown as twenty-four hex characters, used as the default document primary key, with a timestamp in the first four bytes.
Can I read the date from an ObjectId?
Yes. The first four bytes are a Unix timestamp. The decoder extracts it and shows the creation date in UTC.
Do ObjectIds sort by creation time?
Roughly, yes. Because the timestamp leads the id, sorting ObjectIds orders documents approximately by when they were created.
Are the generated ids valid for MongoDB?
They are valid twenty-four-character ObjectIds with correct timestamps, suitable for test data. Real drivers add machine and process identifiers, which these approximate with randomness.
How many can I generate at once?
Up to one thousand at a time, which is convenient for seeding test collections or generating fixtures in bulk.
Privacy & Security
Everything runs in your browser; nothing is uploaded.
How to Use
Generate ObjectIds or paste one to decode its timestamp.
Disclaimer: This tool is provided "as is" without warranty of any kind. Results are for educational and utility purposes.
Related Tools
JSON Formatter
DeveloperFormat and beautify JSON in your browser. Pinpoints syntax errors by line and column, flags unsafe integers, and never uploads your data to a server.
JSON Validator
DeveloperValidate JSON syntax with precise line and column errors, and check documents against a JSON Schema. Runs locally in your browser, nothing uploaded.
Regex Tester
DeveloperTest regular expressions against sample text with live match highlighting, capture groups and flag control. Runs entirely in your browser.