Mint MongoDB ObjectIds for fixtures and test data

Seed data needs IDs that sort by creation and look real. Generate a batch of proper 24-hex ObjectIds without a database.

Tools used in this guide

The job

Writing fixtures or a migration script and you need fifty ObjectIds that parse as genuine — 24 hex chars, timestamp-led, monotonic-ish. Hand-typing hex produces duplicates and IDs that sort wrong.

Set count, get IDs

Choose how many (up to 500) and generate. Each ID follows the real layout: 4-byte seconds timestamp, 5-byte random value, 3-byte counter — so they sort in creation order like real ones.

  • Every ID is shown with its embedded timestamp decoded — sanity-check that the batch spans the seconds you expect.
  • Counter resets per process mean IDs generated in different sessions can share a counter start — fine for fixtures, noted for realism.

Not for production

These are structurally correct IDs for tests and seeds. In production the driver generates ObjectIds with per-process uniqueness guarantees this page doesn't provide — don't mint real document IDs here.