Hunt
Skip to content

MongoDB ObjectId Decoder

Paste one or more MongoDB ObjectIds to see when each was created, plus its random and counter parts. Or go the other way: choose a date to get the ObjectId to compare _id with, and a ready-made query for documents created in that range. Nothing is uploaded.

Runs in your browser

ObjectIds

One per line; ObjectId("…") and {"$oid": …} work too

Decoded

Paste an ObjectId to see when it was created.

    ObjectId for a date

    Find documents created after (or between) dates by comparing _id, which uses the _id index.

    Dates without a time zone are read as UTC.

    Inside an ObjectId

    An ObjectId is 12 bytes, written as 24 hex digits: a 4-byte timestamp (seconds since 1970, so it sorts roughly by creation time), 5 random bytes chosen once per process, and a 3-byte counter that starts at a random value. That's why _ids from one server count up by one.

    The timestamp has one-second precision and comes from the clock of whatever created the document, usually the application's driver, not the database server.

    How to use the MongoDB ObjectId Decoder

    1. Paste ObjectIds, one per line, or press Sample.
    2. Read the creation time in UTC and your time zone.
    3. To query by date, enter a start date (and optionally an end date) and copy the query.

    Examples

    The ObjectId from MongoDB's documentation

    Input
    507f1f77bcf86cd799439011
    Output
    2012-10-17T21:13:27.000Z

    Shell syntax is accepted

    Input
    ObjectId("507f191e810c19729de860ea")
    Output
    2012-10-17T20:46:22.000Z

    A query for November 2026

    Input
    from: 2026-11-01T00:00:00Z
    to: 2026-12-01T00:00:00Z
    Output
    { _id: { $gte: ObjectId("6ae681000000000000000000"), $lt: ObjectId("6b0e0e000000000000000000") } }

    Documents created during November 2026, in UTC, using the _id index.

    Querying by creation date

    Every collection has an index on _id, so filtering by an ObjectId range is fast even without a createdAt field. An ObjectId whose remaining 8 bytes are zero is the smallest possible for its second, so { _id: { $gte: ObjectId("<that id>") } } finds everything created from that moment on.

    Limitations

    • Times have one-second precision and reflect the clock of the machine that created the ObjectId.
    • Applications can set _id themselves: a custom ObjectId's timestamp may not be its real creation time.

    Frequently asked questions

    Is my data uploaded?

    No. ObjectIds are decoded in your browser; nothing you paste is sent anywhere.

    How do I get the timestamp in code?

    In mongosh, ObjectId("…").getTimestamp(). In Node.js, new ObjectId(id).getTimestamp(). In JavaScript without a driver, new Date(parseInt(id.slice(0, 8), 16) * 1000).

    Are ObjectIds unique?

    In practice, yes: the timestamp, the per-process random value and the counter make collisions extremely unlikely. They're not secret, though: anyone can read the creation time.