BSON document size calculator
Paste a document to get its exact BSON size in bytes, see how close it is to MongoDB's 16 MB document limit, and find the fields taking up the most space.
Runs entirely in your browser. Nothing you paste is sent to any server.
Files are read by your browser and never uploaded. Plain numbers are typed like mongosh: 32-bit integers as int32, everything else as double.
Size
BSON size
491 B
491 bytes
Of the 16 MB limit
<0.01%
16.00 MB to spare
Fields / depth
21 / 3
Elements at every level
Biggest fields
| Field | Type | Size |
|---|---|---|
| reviews | array | 192 B |
| reviews.0 | object | 101 B |
| thumbnail | binData | 86 B |
| attributes | object | 82 B |
| reviews.1 | object | 77 B |
| reviews.0.text | string | 67 B |
| reviews.1.text | string | 43 B |
| title | string | 34 B |
| price | decimal | 23 B |
| sku | string | 22 B |
| attributes.material | string | 21 B |
| updatedAt | date | 19 B |
| _id | objectId | 17 B |
| attributes.fit | string | 17 B |
| attributes.color | string | 15 B |
| reviews.0.user | string | 14 B |
| reviews.1.user | string | 14 B |
| attributes.size | string | 12 B |
| reviews.0.rating | int | 12 B |
| reviews.1.rating | int | 12 B |
| stock | int | 11 B |
A field's size includes its key name, a type byte and everything nested inside it. The document adds 5 bytes of framing.
Do this against your real data with MotionQL
MotionQL's schema analysis shows field types and structure across a whole collection, with CSV, Markdown and HTML reports. Pro is free for a year.
Keeping documents small
- Unbounded arrays are the usual reason documents approach 16 MB. Use the bucket or subset pattern, or move items to their own collection.
- Field names are stored in every document. In collections with millions of documents, a 20-character key costs 20 bytes each time.
- Binary blobs such as images and PDFs belong in GridFS or object storage, with only a reference in the document.
- Pick the right number type. An int32 takes 4 bytes, a double or long 8, and a Decimal128 16.
Questions, answered
More free MongoDB tools
Connection string builder
Build or parse mongodb:// and mongodb+srv:// URIs. Split a pasted URI into hosts, credentials and options, catch common mistakes, and copy a correctly encoded string with the password masked.
Open toolObjectId converter
Decode a MongoDB ObjectId into its creation time, random value and counter, decode many at once, or generate ObjectIds for any date to query by time range.
Open toolExtended JSON converter
Convert MongoDB documents between canonical Extended JSON, relaxed Extended JSON and mongosh shell syntax, keeping BSON types like ObjectId, Date, Long and Decimal128 intact.
Open toolExplain plan analyzer
Paste the output of explain() to see the plan as a tree, catch collection scans and in-memory sorts, compare documents examined with documents returned, and get an index suggestion.
Open toolOperators cheat sheet
Searchable reference of MongoDB query, update and aggregation operators and pipeline stages, each with example syntax and a link to the official documentation.
Open tool