Loading CSV to BSON Converter...
Please wait a moment

How to Convert CSV to BSON - Step by Step Guide

Step 1

Input Your CSV Data

Let's convert your CSV data to BSON format! Whether you're preparing spreadsheet data for MongoDB imports, working with database exports, or optimizing storage, you have several convenient options:

•
Paste directly: Copy your CSV data from Excel, databases, or data exports
•
Upload a file: Click "Upload" to select a .csv or .txt file from your computer
•
Try the sample: Click "Sample" to load example CSV and see the BSON conversion

Example: CSV Input

Here's a typical CSV structure ready for BSON conversion:

id,name,email,age,department,isActive
1,Robert Wilson,[email protected],30,Engineering,true
2,Jane Smith,[email protected],28,Marketing,true
3,Mike Johnson,[email protected],35,Sales,false
Step 2

Configure Parsing Options

Customize how your CSV is parsed and converted to BSON binary data:

•
Header handling: Choose whether first row contains column names for proper data mapping
•
Custom delimiters: Support for comma, semicolon, tab, or pipe separators
•
Output format: Choose Base64 (compact) or Hex (debug-friendly) encoding for the BSON binary data
•
Automatic conversion: CSV automatically converts to JSON first, then encodes to BSON with MongoDB-specific type optimization

Example: BSON Output (Base64)

The same CSV, now encoded as BSON in Base64 format:

VgAAAAJkb2N1bWVudHMABQAAAAACAAAAAmRvY3VtZW50cwADAAAAAAJpZAAEAAAAAQJuYW1lAA8AAABSb2JlcnQgV2lsc29uAAJlbWFpbAAUAAAAcm9iZXJ0QGV4YW1wbGUuY29tAARhZ2UAIAAAABAEZGVwYXJ0bWVudAAKAAAARW5naW5lZXJpbmcACWlzQWN0aXZlAAEAAA==
Step 3

Export Your BSON Data

Get your encoded BSON ready for MongoDB! Multiple export options make integration seamless:

•
Copy to clipboard: One-click copying for quick pasting into MongoDB Compass or application code
•
Download as .bson: Save binary file for direct use with mongorestore and MongoDB imports
•
Ready for MongoDB: Optimized binary format with proper type information for efficient database operations

Frequently Asked Questions

How do I convert CSV to BSON for MongoDB?

Simply paste your CSV data into the converter, configure parsing options (headers, delimiter), choose your preferred output format (Base64 or Hex), and the tool automatically converts CSV to JSON first, then encodes it to BSON. Whole numbers become int32 or int64, decimals become doubles, true/false become booleans and empty cells become null. Anything the conversion would change, such as a zip code like 00501, 14.50 or a date, is kept as a string.

What's the difference between Base64 and Hex output?

Both represent the same BSON binary data as text. Base64 is more compact and commonly used for APIs and web transmission. Hex is easier to debug byte-by-byte and useful for development and troubleshooting.

How do I import the BSON into MongoDB?

Set Layout to "One document per row", download the .bson file and run mongorestore on it. That is the same layout mongodump writes, so each CSV row lands as its own document. The default layout wraps all rows in one { documents: [...] } document, which is easier to decode in code before inserting the rows with a MongoDB driver.

Does the converter support different CSV delimiters?

Yes! The converter supports comma, semicolon, tab, and pipe delimiters. You can also handle quoted fields containing delimiter characters. Quoted fields may contain line breaks too, and files saved by Excel (with a BOM or in Windows-1252) open correctly. The delimiter isn't guessed, so pick the one your file uses.

Can I convert large CSV files to BSON?

Yes. Everything runs in your browser, so the file never leaves your machine. A single BSON document tops out at 16 MB, though, so for big files set Layout to "One document per row" and only each row has to fit under that limit.

Is this CSV to BSON converter free?

Yes, completely free with unlimited conversions. No registration required, and you can convert as much CSV to BSON as needed. All processing happens locally in your browser for security and privacy.