MongoDB ObjectId Decoder (Timestamp)
Software · 1 inputs · Free
MongoDB ObjectId Decoder (Timestamp)
Parameters
What is this tool?
MongoDB ObjectId Decoder (Timestamp) helps developers with encoding, encryption and text processing. Splits a 24-character hexadecimal MongoDB ObjectId into its parts: the creation time stored in the first 4 bytes (ISO 8601 UTC and Unix seconds), the 5-byte random value and the 3-byte counter. A value pasted as ObjectId("…") is accepted too. The time reflects the clock of the machine that generated the id; it does not show when the document was last modified.
📘 Common mistakes · Worked exampleSplits a 24-character hexadecimal MongoDB ObjectId into its parts: the creation time stored in the first 4 bytes (ISO 8601 UTC and Unix seconds), the 5-byte random value and the 3-byte counter. A value pasted as ObjectId("…") is accepted too. The time reflects the clock of the machine that generated the id; it does not show when the document was last modified.
The result is not exact or binding and is for information only; it is not an official document and cannot be used in official procedures. Confirm it with the competent authority or a professional before acting; no liability is accepted for losses arising from its use.
Last reviewed: · Methodology and sources
How is it calculated?
Splits a 24-character hexadecimal MongoDB ObjectId into its parts: the creation time stored in the first 4 bytes (ISO 8601 UTC and Unix seconds), the 5-byte random value and the 3-byte counter. A value pasted as ObjectId("…") is accepted too. The time reflects the clock of the machine that generated the id; it does not show when the document was last modified.
Inputs
| Value | Unit | Example |
|---|---|---|
| ObjectId | — | 507f1f77bcf86cd799439011 |
What is this tool?
MongoDB ObjectId Decoder (Timestamp) helps developers with encoding, encryption and text processing. Splits a 24-character hexadecimal MongoDB ObjectId into its parts: the creation time stored in the first 4 bytes (ISO 8601 UTC and Unix seconds), the 5-byte random value and the 3-byte counter. A value pasted as ObjectId("…") is accepted too. The time reflects the clock of the machine that generated the id; it does not show when the document was last modified.
Common mistakes
- Reading the ObjectId date as the document's last update time. The identifier is generated once and never changes when the document does; keep a separate field for update times.
- Reading the date as local time. The timestamp is UTC and the tool shows UTC; apply your own offset if you need local time.
- Expecting millisecond precision. The time part is whole seconds; for identifiers generated within the same second the order is decided by the random value and the counter, not by time.
- Using an ObjectId as an unguessable secret. The time part is public, the random value is constant for the life of the process and the counter goes up by one, so neighbouring ids from one process look very much alike. Do not base authorisation on the id being secret.
- Confusing a 24-character string with the ObjectId type. The string "507f1f77…" and ObjectId("507f1f77…") are different BSON types; a query with the wrong type finds nothing.
- Interpreting the middle 5 bytes as a machine id. The current MongoDB manual defines this part as a random value generated per process; it changes when the process restarts and does not reliably identify a server.
- Treating a sort on _id as strict chronological order. There is no ordering guarantee within a second or across clients; if you need strict order, use a dedicated time field or a sequence number.
📘 How to Get the Date from a MongoDB ObjectId: The 12 Bytes Explained →
Sources
- MongoDB Manual — ObjectId() (composition of the 12 bytes, getTimestamp) ↗
- MongoDB Manual — BSON Types: ObjectId (ordering and the one-second resolution note) ↗
- RFC 9562 — Universally Unique IDentifiers (UUIDs) (for comparison) ↗
Key terms
Frequently Asked Questions
+MongoDB ObjectId Decoder (Timestamp) — how is it calculated?
Splits a 24-character hexadecimal MongoDB ObjectId into its parts: the creation time stored in the first 4 bytes (ISO 8601 UTC and Unix seconds), the 5-byte random value and the 3-byte counter. A value pasted as ObjectId("…") is accepted too. The time reflects the clock of the machine that generated the id; it does not show when the document was last modified.
+Which values are required?
ObjectId.
+Is my data stored?
No. All calculations run in your browser; the values you enter are never sent to or stored on a server. If you press “Save”, the calculation stays only in your own browser and you can delete it at any time.
+Is it free?
Yes, all tools are free and require no sign-up.
Similar tools
Popular Tools
Free Calculators in One Place
Tax, finance, health, math and more — 500+ tools, all in one place.