Loading BSON Minifier...
How to Minify BSON - Step by Step Guide
Input Your BSON Data
BSON is the binary format MongoDB stores documents in. To get it onto this page you can:
0x-prefixed hex dumps are fine.Example: BSON Input (Base64)
The sample is a 133-byte BSON document, written as Base64:
hQAAAAJjdXN0b21lcklkAAsAAABDVVNULTEyMzQ1AAJwaG9uZU51bWJlcgAOAAAAKzE1NTUtMTIzNDU2NwACcGxhblR5cGUADQAAAFVubGltaXRlZCA1RwASaWNjaWQARiiCMx2Ph3sQZGF0YVVzYWdlR0IALQAAAAhpc0FjdGl2ZQABAA==
Automatic Decoding
About half a second after you stop typing, the bytes are decoded and written as Extended JSON on a single line.
$oid, $date, $binary and $numberDecimalGet the One-Line JSON
This is what the sample above turns into:
Minified JSON Output
{"customerId":"CUST-12345","phoneNumber":"+1555-1234567","planType":"Unlimited 5G","iccid":8901240544102066246,"dataUsageGB":45,"isActive":true}144 characters, against 169 for the same JSON indented with two spaces, so the badge reads about 15% smaller.
Export the JSON
What is BSON Minification?
BSON has no whitespace of its own, so "minifying" it really means decoding the binary document and writing it as the shortest JSON text that still carries every value. MongoDB-specific types travel as Extended JSON wrappers, and long integers are written out in full.
The result is the same data as the BSON Formatter shows, just without the indentation. If you would rather see the documents as rows and columns, try BSON to Table.
Related Tools
BSON to JSON
Convert MongoDB BSON binary format to JSON for debugging and analysis
JSON to BSON
Convert JSON to MongoDB BSON format for database imports
BSON Fixer
Fix broken BSON Extended JSON automatically, repair malformed MongoDB documents, ObjectIds, and type wrappers
BSON Validator
Validate MongoDB BSON data integrity and structure with type detection
CSV to BSON
Convert CSV spreadsheet data to MongoDB BSON format
BSON Formatter
Format and beautify BSON data with proper JSON indentation
Frequently Asked Questions
What does "minifying BSON" actually mean here?
BSON itself is binary and has no whitespace to remove. This page decodes the BSON you paste or upload and writes it as Extended JSON on a single line, with no spaces or line breaks between keys and values. That one-line form is handy for log lines, test fixtures, curl bodies and anywhere a pretty-printed document would be in the way.
How much smaller is the output?
The badge compares the one-line JSON with the same JSON indented by two spaces, so you see the real saving for your data. For the sample document it is about 15%. Deeply nested documents save more, flat ones with long string values save less. It is not a comparison with the size of the BSON bytes.
Are long integers and MongoDB types kept?
Yes. A 64-bit value such as an ICCID 8901240544102066246 is written with every digit, not rounded the way JavaScript usually rounds big numbers. ObjectId, Date, Binary, Decimal128 and regular expressions keep their $oid, $date, $binary, $numberDecimal and $regularExpression wrappers, so a Decimal128 14.50 stays "14.50". Plain numbers come out as ordinary JSON numbers, which means the text no longer says whether a value was a BSON int32, int64 or double.
Can I minify a whole mongodump file?
Yes. A .bson file from mongodump holds documents written back to back. Upload it and you get a JSON array with one entry per document, all on one line. If the file is cut off or has stray bytes at the end, the message says which document is affected.
When should I use the formatter instead?
Use the minifier when the JSON goes into something else: a request body, a single log line, a fixture file. When you want to read the documents yourself, the BSON Formatter shows the same data indented, and BSON to Table lays it out as rows and columns.
Is my data uploaded anywhere?
No. Decoding and minifying happen in your browser and nothing you paste or upload is sent to our server. A reload starts with an empty editor. Very large files are limited by your browser memory and can take a few seconds.