Get Started Free

More information about MongoDB ObjectIds

Every MongoDB document has an _id, and by default it's an ObjectId: a 12-byte value shown as 24 hexadecimal characters. It isn't random, it's structured, which is why you can pull a creation time straight out of it.

What's inside an ObjectId?

Why it's useful

Because the timestamp is the first 4 bytes, ObjectIds are roughly sortable by creation time, and you can query by time range without a separate date field: { _id: { $gt: ObjectId("...") } }. Use the "ObjectId for a date" box above to build the boundary value.

Frequently asked questions

VisuaLeaf

Browse and query ObjectIds visually in VisuaLeaf

VisuaLeaf shows human-readable timestamps for your ObjectIds, lets you build _id range queries visually, and gives you a full MongoDB and SQL client with query builders, schema diagrams, and charts.

MongoDB & SQL in one client
Visual query & aggregation builders
Live visual schema diagrams
Charts, dashboards & query profiler
Connection manager for local, cloud & teams
Free Community Edition