Loading Techie Utils…

ObjectID to Timestamp

Read the creation time, process value and counter out of a MongoDB ObjectID. Free, and runs entirely in your browser — nothing is uploaded.

About ObjectID Generator

An ObjectID is what MongoDB puts in _id when you do not supply one: twelve bytes shown as twenty-four hexadecimal characters. Four bytes of seconds since 1970, five bytes drawn once per process, and a three-byte counter that increments with every document.

That shape makes it sortable by creation time to the second, which is what it was built for — inserts land at the end of the index instead of scattering across it. It also means the time is readable out of any ObjectID with no key, which this tool will do for you.

What it is not is random. Only five of the twelve bytes are random, and they are the same for every identifier a process emits. Two ObjectIDs from one server differ by a counter that simply counts, so holding one lets somebody guess its neighbours — and the gap between any two tells them how many documents were created in between, which is a volume figure nobody meant to publish.

Identifiers generated here share one process value and step the counter, the way a driver does. Drawing a fresh random for each would be perfectly valid and would look nothing like the identifiers in a live collection, which makes it useless as test data.

Where it helps

  • The same twelve-byte layout MongoDB's own drivers produce, counter and all.
  • Sortable by creation time, which is the property it exists for.
  • Decodes back to a timestamp, the process value and the counter with no key.
  • A run looks like a run, so it works as test data rather than as twenty-four random characters.

Limits

  • Only five of twelve bytes are random, and they repeat across a process — it is not a random identifier and should not be treated as one.
  • The counter leaks how many documents were created between any two identifiers.
  • The timestamp is a second, so ordering within a second comes from the counter rather than from the clock.
  • For anything public, or anywhere guessing matters, a UUID v4 or a Nano ID carries real randomness in every byte.

Frequently asked questions

Is an ObjectID safe to expose in a URL?

Not if guessing one would matter. Given a single ObjectID, the ones near it in the same process differ only by a small counter, so enumerating neighbours is arithmetic rather than search. Use it as MongoDB's key and expose something with real randomness.

Why do mine all look nearly the same?

Because they should. Within one process only the counter changes, so a run differs in its last few characters. That is what a real driver produces, and an identifier generator that made them look unrelated would be misleading.

Does it still use the machine and process ID?

Not since MongoDB 3.4. The old layout put a machine hash and a process ID in those bytes, which disclosed rather more than anyone wanted; they are now five random bytes per process, which is what this produces.

Related tools

  • UUID Generator — UUID v1 to v7 — generate any version, or read what one encodes
  • ULID / CUID Generator — Sortable, collision-resistant identifiers — and the timestamp inside one
  • KSUID Generator — Sortable 27-character identifiers with a second of time and 128 bits of randomness
  • Nano ID Generator — Short, URL-safe random identifiers — and what the length actually buys
  • TypeID Generator — Type-prefixed identifiers over UUID v7, readable and still a UUID underneath
  • Barcode Generator — Draw QR, Data Matrix, Code 128, EAN and more as SVG

More Generators tools

  • UUID Generator — UUID v1 to v7 — generate any version, or read what one encodes
  • ULID / CUID Generator — Sortable, collision-resistant identifiers — and the timestamp inside one
  • Nano ID Generator — Short, URL-safe random identifiers — and what the length actually buys
  • KSUID Generator — Sortable 27-character identifiers with a second of time and 128 bits of randomness
  • TypeID Generator — Type-prefixed identifiers over UUID v7, readable and still a UUID underneath
  • ObjectID Generator — MongoDB's twelve bytes — a timestamp, a process value and a counter
  • Barcode Generator — Draw QR, Data Matrix, Code 128, EAN and more as SVG
  • QR Code Generator — Create scannable QR codes as SVG
  • UPI QR Code Generator — Make a UPI payment QR code that any UPI app can scan to pay you
  • Diagram Studio — Draw architecture, sequence, ER, C4, network and nine other diagrams by dragging shapes and connecting them
  • Random String — Random identifiers from a chosen alphabet
  • Lorem Ipsum — Placeholder paragraphs, sentences or words
  • Fake Data — Synthetic people and companies as JSON, CSV or SQL
  • Random Number Generator — Draw uniformly random integers or decimals in a range, with or without repeats