Generate ObjectIds, decode the embedded timestamp, build $gte/$lte bounds for a time range — all in your browser
- Runs locally
- Category Developer & DevOps
- Best for Formatting, validating, shrinking, or inspecting code-adjacent text.
The decoded creation time shows up here.
Pick a time and get the lowest and highest ObjectId for that second — paste them into a Mongo $gte / $lte range query.
What this tool does
A MongoDB ObjectId generator and decoder that runs entirely in your browser. An ObjectId is the 12-byte value MongoDB drops into the _id field by default, shown as a 24-character hex string. Its layout is fixed: 4 bytes of Unix timestamp in whole seconds, 5 random bytes generated once per process, then a 3-byte counter. This tool mints fresh ObjectIds in batches of 1 to 100 using crypto-grade randomness, decodes any ObjectId you paste back into its creation time (seconds, UTC and your local zone), and builds the lowest and highest ObjectId for a chosen second so you can run a fast _id range query instead of scanning a createdAt column. Every byte is computed locally with plain JavaScript, nothing is uploaded, and a shareable URL carries your settings and the id you are inspecting. Ideal for debugging documents, scripting backfills and reading the clock that is already baked into your primary key.
Tool details
- Input
- Numbers
- The page exposes text boxes, numeric controls, file pickers, or structured inputs depending on the tool.
- Output
- Live result + Copy + Download
- The result area focuses on usable output, with copy, download, or preview actions when supported.
- Privacy
- Browser-side processing
- The main tool logic does not call an external API, so inputs normally stay in the current tab.
- Save / share
- Shareable URL state
- Key settings are encoded in the URL so another person can reopen the same setup.
- Performance budget
- Initial JS <= 9 KB
- No WASM budget is declared, keeping the tool quick to open on mobile.
- Best fit
- Developer & DevOps · Developer
- Category and role tags drive related tools, internal links, and quick fit checks.
How to use
-
1. Input
Paste or drop your content into the tool panel.
-
2. Process
Click the button. All processing is local in your browser.
-
3. Copy / Download
Copy the result or download to disk in one click.
How MongoDB ObjectId Generator & Decoder fits into your work
Use it in the small gaps between coding, reviewing, debugging, and shipping.
Developer jobs
- Formatting, validating, shrinking, or inspecting code-adjacent text.
- Preparing snippets for documentation, tickets, commits, or handoff.
- Checking a small payload quickly without switching tools.
Developer checks
- Run irreversible transforms like minify or obfuscate on a copy.
- Keep secrets out of pasted snippets unless the tool explicitly stays local.
- Use your normal tests or linter before shipping transformed code.
Good next steps
These links move the current task into a more complete workflow.
- 1 NanoID Generator Generate URL-safe NanoIDs with a custom alphabet, adjustable length, and a live collision-probability readout — entirely in your browser. Open
- 2 UUID Generator Generate v4 random, v7 time-ordered, NIL, and Short UUIDs instantly — entirely in your browser. Open
- 3 ULID Generator Sortable, URL-safe unique IDs — batch generate, monotonic mode, decode the timestamp back out — 100% in your browser Open
Real-world use cases
Debug a document by reading its insertion time
You pull a record out of a collection and want to know when it was created, but there is no createdAt field. Paste the _id into the decoder and you get the exact second the document was inserted, in UTC and your local time. No extra query, no schema change — the clock was in the primary key the whole time.
Backfill or migrate documents in a time window
A migration script needs every document created on a given day. Build the lowest ObjectId for the start of that day and the highest for the end, then query _id between those bounds. Because _id is already indexed the scan is fast, and you avoid adding a temporary createdAt index just to slice by time.
Generate stable ObjectIds for test fixtures
Your integration tests need a handful of realistic _id values that look like the real thing and sort in a predictable order. Generate a batch, copy them into your seed file, and the counter increment keeps them strictly ascending so any "order by _id" assertion stays stable across runs.
Explain ObjectId structure to a teammate
Onboarding someone who has only seen auto-increment integer keys? Generate one ObjectId, decode it, and walk through the timestamp, random and counter bytes live. The shareable URL reopens the exact id and decoded view, so you can drop it into a chat message and have them see what you see.
Common pitfalls
Treating the ObjectId timestamp as milliseconds. The leading 4 bytes hold whole seconds, so the embedded time has one-second resolution. Two documents inserted 100 ms apart can carry the same ObjectId second; rely on the counter, not the time, to order them within that second.
Sorting by _id and expecting perfect chronological order across machines. The counter and random field only guarantee order within one process; ids from two servers in the same second can interleave. For strict cross-host time ordering keep a real timestamp field.
Building range-query bounds by hand and forgetting the trailing bytes. The low bound must zero the random and counter bytes and the high bound must max them out; using a bare 8-hex timestamp with random tail bytes will silently miss documents at the edges of the window.
Privacy
Every ObjectId is built and decoded by plain JavaScript inside your browser tab — the random bytes come from the local crypto API and no id, timestamp or query bound is ever sent to a server. There is no logging of what you generate or paste. The one caveat: the shareable URL encodes your settings and the ObjectId in the decoder into the query string, so a link pasted into chat records that id in the recipient server access log. If the id maps to a sensitive document, use the copy button and paste the text rather than sharing the URL.
FAQ
Tool combos
Folks in your role tend to reach for these alongside this tool.
- Add Line Numbers Number every line of pasted text — set start, step and separator, zero-pad to align, skip blanks, or strip numbers back off — browser-only
- AES Text Encryptor Encrypt & decrypt text with a password — AES-256-GCM + PBKDF2 via WebCrypto — 100% in your browser, nothing uploaded
- Affine Cipher Encoder & Decoder Encrypt and decrypt the ax+b affine cipher with live modular-inverse check, browser-only
- Age Difference Calculator The exact gap between two birthdays — years/months/days, percentage, and the date one person is twice the other's age — browser-only