Loading BSON Formatter...

How to Format BSON - Step by Step Guide

Step 1

Input Your BSON Data

Let's format your BSON data! Whether you're debugging MongoDB exports, analyzing database dumps, or converting for better readability, you have several convenient options:

•
Paste directly: Copy your BSON data in Base64 or Hex format from mongodump exports or MongoDB drivers
•
Upload a file: Click "Upload" to select a .bson or .bin file from your computer
•
Choose format: Select Base64 (compact) or Hex (debug-friendly) encoding
•
Try the sample: Click "Sample" to load example BSON and see the formatting in action

Example: Unformatted BSON Input (Base64)

Here's what raw, unreadable BSON data looks like:

dgAAAAJjdXN0b21lcklkAAsAAABDVVNULTEyMzQ1AAJwaG9uZU51bWJlcgAOAAAAKzE1NTUtMTIzNDU2NwACcGxhblR5cGUADQAAAFVubGltaXRlZCA1RwAQZGF0YVVzYWdlR0IALQAAAAhpc0FjdGl2ZQABAA==
Step 2

Automatic Formatting & Validation

About half a second after you stop typing, the formatter:

•
Decodes BSON: Converts binary BSON to readable JSON format
•
Checks the bytes: Stops with a message when a document is cut off, has stray bytes after it, or the text isn't valid Base64 or Hex
•
Adds proper indentation: Makes nested objects and arrays easy to read with 2-space indentation
•
Keeps MongoDB types readable: Writes ObjectId, Date, and other MongoDB-specific data types in Extended JSON format
•
Keeps long integers exact: A 64-bit value like 8901240544102066246 is written with every digit, not rounded

Example: Beautifully Formatted Output (JSON)

The same BSON, now decoded and properly formatted:

{
  "customerId": "CUST-12345",
  "phoneNumber": "+1555-1234567",
  "planType": "Unlimited 5G",
  "dataUsageGB": 45,
  "isActive": true
}
Step 3

Choose Format Options

Customize your output based on your needs! The formatter gives you control over how your JSON appears:

•
Pretty format: Default beautified JSON with proper indentation (2 spaces) for debugging
•
Minify option: Click "Minify" to put the same JSON on a single line
•
Extended JSON: MongoDB types are preserved in Extended JSON (EJSON) format for accuracy
Step 4

Export Your Formatted JSON

Copy and Download both give you exactly what is on screen, indented or minified:

•
Copy to clipboard: One-click copying for quick pasting into your code editor, documentation, or MongoDB Compass
•
Download as JSON: Save as a .json file for sharing, analysis, or integration with other tools
•
Status badge: "Valid BSON" appears once the current input has been decoded; broken input shows "Invalid BSON" with the reason

Frequently Asked Questions

How do I format BSON from MongoDB?

Paste the BSON bytes as Base64 or Hex, or upload the .bson file (a mongodump file works too). The page decodes it and shows the documents as Extended JSON indented with two spaces. A file with several documents back to back comes out as a JSON array, one entry per document.

What's the difference between Base64 and Hex input?

They are two text spellings of the same bytes. Base64 is shorter, so APIs and logs tend to use it; Hex takes two digits per byte and is easier to read byte by byte. Pick the one you pasted. If you pick the wrong one, the error message tells you which format the text looks like.

Can I both format and minify BSON?

Yes. The output is indented by default. Minify writes the same JSON on a single line, and Copy and Download always give you exactly what is on screen. Editing the input switches back to the indented view.

Are MongoDB types preserved when formatting?

The output is relaxed Extended JSON, so ObjectId, Date, Binary, Decimal128, Timestamp and regular expressions keep their $oid, $date, $binary, $numberDecimal, $timestamp and $regularExpression wrappers. Long integers such as 8901240544102066246 are written with every digit. Ordinary numbers become plain JSON numbers, which means the text no longer says whether a value was a BSON int32, int64 or double, and a double like 14.50 is shown as 14.5.

What happens if the BSON is broken?

You get a message instead of output. It names a bad Base64 or Hex character with its line and column, says when a document is cut off or has stray bytes after it, and tells you when you pasted JSON text instead of BSON.

Is my data uploaded anywhere?

No. Decoding and formatting happen in your browser and nothing you paste or upload is sent to our server. The tool is free and needs no account. Big files are limited by your browser memory and can take a few seconds to show.