Generate Random BSON
Generate random BSON (Binary JSON) files. Runs entirely in your browser, so your data never leaves your device.
Runs on your device, nothing uploaded
Output
Generating…
This runs entirely on your device
Generate Random BSON is JavaScript that your browser has already downloaded, and it does the whole job on your own machine. Nothing is requested from a server, so the result you see has never existed anywhere but here.
- No server involved
- Generated on your device
- Works offline once loaded
- Nothing stored or logged
How to use Generate Random BSON
- 1. Set the number of fields. Enter Number of fields to decide how many key-value entries the generated BSON document contains before it gets encoded to bytes.
- 2. Switch between JSON and bytes. Switch Show between As JSON, which decodes the generated document, and Bytes, which prints its raw bytes as hex pairs.
- 3. Check the structure. The bytes follow BSON's length-prefixed, type-tagged binary structure used by MongoDB, and the JSON view is decoded from exactly those bytes.
- 4. Download the .bson file. Click Download to save the binary random.bson file for a MongoDB import test, or copy the hex into a hex editor or documentation.
When to use Generate Random BSON
Generate Random BSON builds a small BSON (Binary JSON) document with a chosen number of fields and outputs its raw bytes as hex, the format MongoDB uses internally to store and transmit documents.
- Learning how BSON encodes a document. A developer new to MongoDB internals wants to see the actual byte layout of a document, including type tags and length prefixes, rather than just reading the spec.
- Testing a BSON parser implementation. Someone writing a custom BSON decoder in a language without an existing library wants sample byte sequences to confirm the parser reads field types and lengths correctly.
- Comparing BSON size against equivalent JSON. A developer curious how much overhead BSON's type tags and length prefixes add generates a sample document to compare its byte size against the same data in JSON.
- Debugging a MongoDB wire protocol issue. An engineer troubleshooting a driver-level bug wants a known-structure BSON byte sequence to trace through a packet capture and confirm field boundaries.
Examples
Three-field BSON document as hex bytes
One possible result
2c 00 00 00 10 70 65 61 72 6c 00 32 03 00 00 08 69 6e 64 69 67 6f 00 00 02 73 69 65 72 72 61 00 07 00 00 00 6c 61 67 6f 6f 6e 00 00
Three-field BSON document as JSON
One possible result
{
"pearl": 818,
"indigo": false,
"sierra": "lagoon"
}About the Generate Random BSON tool
Generate Random BSON does its work locally, right in the browser. Generate random BSON (Binary JSON) files. There is no upload step, no queue and no account, and your data never travels over the network.
It belongs to the Random Tools collection on EditSafely, a set of 120 small, focused Random utilities that share the same instant, private workspace.
You can shape the output with 3 settings, including Show, Number of fields and Byte separator, and the result refreshes the moment you change one. 2 worked examples further down the page show exactly what the tool produces for real inputs.
Running locally also makes the tool fast and dependable: results appear as soon as your input does, there is no server outage that can take it down mid-task, and confidential data can be processed without a second thought.
Frequently asked questions
Is Generate Random BSON free to use?
Yes, it is completely free. All 2,943 tools on EditSafely work without an account, a subscription or usage limits.
Does the generator send anything to a server?
Everything happens locally. Your browser downloads the tool's code once, then does all the processing itself; nothing you enter is transmitted, stored or logged. You can even go offline after the page loads and it will still work.
How do I get a different result?
Press the button under the result to generate again. Each run is computed fresh on your device, and any options you change are applied to the next result immediately.
Do I need to sign up or install anything?
No. The tool works in any modern browser on desktop, tablet or phone. There is no account to create, no extension to add and no software to install.
How do I use the result?
The output panel has a one-click Copy button, and Download saves the result as a file.