Identifiers

ObjectId generatorGenerate, decode and inspect

Choose generation, decoding or a date query boundary.

ObjectId generator

Input

Results

Byte structure

4-byte unsigned timestamp, 5-byte random value, and 3-byte counter. Random bytes do not reveal a machine ID or PID.

Your input is processed in this browser and is not sent to a server.

Options

Decode: one 24-hex ObjectId per line. Generate: leave empty for now, or enter one time. Lower bound: one time per line. Use integer Unix seconds or ISO with seconds and Z or ±HH:mm; spaces are not removed.

Up to 1,000 lines and 100,000 UTF-16 code units; generate 1–1,000 IDs. Times must be within 0–4294967295 Unix seconds.

Enter input or choose an example to begin.

An ObjectId generator is useful when API fixtures need realistic identifiers before a database exists. For a value copied from a log, switch to decoding to inspect the time embedded in its first eight hexadecimal characters.

An identifier is evidence of its own bytes. Its timestamp does not prove when a document was inserted, and a valid shape does not establish that a record exists. Keep a separate application timestamp when exact event time matters.

Why use this ObjectId generator?

Read the current byte layout

The ObjectId generator shows the 4-byte timestamp, 5-byte random value and 3-byte counter separately. The middle field stays opaque: modern ObjectIds do not expose a recoverable machine name or process ID.

Twelve bytes divided into four timestamp bytes, five random bytes and three counter bytes.

Keep failures beside valid values

A malformed line should not vanish from an audit. Batch decoding keeps the original line, its position and its error, so the valid total cannot quietly conceal missing input.

A batch report keeps an invalid row between two valid identifiers.

Prepare a value, then check its meaning

01

Choose the intended operation

Generate creates new IDs; Decode reads existing IDs; Date boundary creates a timestamp prefix followed by zero bytes for query comparisons.

  • A date boundary is not a unique ID for insertion.
02

Make time explicit

Leave generation input empty to use the current second. For a chosen instant, enter Unix seconds or an ISO date with Z or an explicit offset.

  • An ObjectId stores whole seconds, not milliseconds.
03

Review the complete batch

Decode accepts one exact 24-character hexadecimal ID per line. Check errors before copying; the report preview is smaller than the exported report. Decode and date boundaries refresh automatically 350 ms after edits by default. Turn automatic conversion off to use Convert or Ctrl/Cmd+Enter. Generation always requires an explicit action; it never runs automatically.

  • Example and Clear use a replacement preview with one-step Undo.

Three operations with inspectable output

Batch generation

Create 1–1,000 lowercase IDs per request. Browser cryptographic randomness seeds a stable random field and a counter that advances for each new ID.

Time extraction

The ObjectId decoder reads an unsigned big-endian Unix timestamp and reports its UTC date, preserving the random and counter fields for comparison.

Date query boundaries

Create a zero-suffix BSON ObjectId for a chosen second. These values help describe time-based query ranges; they do not create or query database documents.

Complete exports

Generation copies or downloads one ID per line as TXT. Decode and boundary modes export JSON reports that retain source lines and errors, including rows outside the visible preview.

Format, clock and batch limits

Exact hexadecimal input
Decode requires 24 ASCII hexadecimal characters per physical line. Uppercase is accepted and normalized to lowercase. Spaces, quotes, ObjectId wrappers and blank lines are errors.
Unsigned seconds
Time values must fall between 0 and 4,294,967,295 Unix seconds: 1970-01-01 through 2106-02-07 06:28:15 UTC. ISO input needs a timezone and whole-second precision.
Bounded input
Input is limited to 100,000 UTF-16 code units and 1,000 lines. Generation accepts an integer count from 1 to 1,000. Oversize input is rejected, rather than silently truncated.
No global ordering promise
Timestamp precision is one second; clocks may differ across clients. A counter increases within this generator context and wraps after 16,777,215. No universal collision-free or total-order guarantee follows.
Local processing
The page does not connect to MongoDB or verify record existence. Random generation requires browser cryptographic APIs. A zero-suffix date boundary must not be treated as a newly generated unique identifier.

ObjectId generator questions

How can I read the date from an ID?

Read the first four bytes as Unix seconds. This page also presents UTC time. That value describes the embedded timestamp, which may be custom or based on a skewed client clock; it is not proof of an insert time.

Do generated IDs work with MongoDB?

The ObjectId generator produces a standard 12-byte layout rendered as 24 lowercase hex characters. Convert that text to your driver's BSON ObjectId type when inserting; a JSON string alone is a different BSON type.

How does it differ from UUID?

ObjectId uses 12 bytes and a second-based time field. UUID uses 16 bytes; its time information depends on the version. UUID v4 is random, whereas v7 includes a millisecond timestamp.

Can I create a batch?

Yes. Choose a count from 1 to 1,000. All IDs in a generated batch share the context's random field and have advancing counters. Copy or download includes the whole batch.

Can I choose a historical timestamp?

Yes. Provide Unix seconds or a whole-second ISO timestamp with an explicit timezone. Use Generate for test identifiers and Date boundary for a repeatable comparison value with a zero suffix.

Found an unexpected value?

Use the ObjectId generator

Try a known value or generate a small fixture batch, then inspect the timestamp and byte fields before exporting.