MotionQL

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

FieldTypeSize
reviewsarray
192 B
reviews.0object
101 B
thumbnailbinData
86 B
attributesobject
82 B
reviews.1object
77 B
reviews.0.textstring
67 B
reviews.1.textstring
43 B
titlestring
34 B
pricedecimal
23 B
skustring
22 B
attributes.materialstring
21 B
updatedAtdate
19 B
_idobjectId
17 B
attributes.fitstring
17 B
attributes.colorstring
15 B
reviews.0.userstring
14 B
reviews.1.userstring
14 B
attributes.sizestring
12 B
reviews.0.ratingint
12 B
reviews.1.ratingint
12 B
stockint
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.
FAQ

Questions, answered

16 MB (16,777,216 bytes) of BSON per document. Larger files belong in GridFS, and documents that keep growing, such as ever-longer arrays, are better split into several documents.

More free MongoDB tools