How to View and Edit BSON

As applications scale, developers need data serialization formats that are compact, fast to parse, and easy to use across modern database systems. One format that continues to gain adoption is BSON (binary JSON).

While BSON is efficient and built for performance, editing raw BSON data directly is not practical because it is a binary format and virtually unreadable by humans. That’s where a professional BSON editor becomes important, offering a human-readable, hierarchical view for easy inspection, editing, and troubleshooting of the data.

To meet this need, XMLSpy now includes a full-featured BSON editor for editing and converting BSON documents in the same familiar environment developers use for working with XML, JSON, and YAML.

What is BSON?

BSON is a binary serialization format designed to encode JSON-like documents in a compact structure that software can quickly parse and navigate. BSON supports standard JSON types like strings, numbers, and arrays. However, since BSON was intended for use primarily by the MongoDB NoSQL database, it has been extended to add some optional non-JSON-native data types, like dates and binary data, which are essential for MongoDB. These include:

  • Date
  • Binary
  • Decimal128
  • ObjectId
  • Timestamp
  • Regular expressions
  • And others

And, unlike JSON, which can be read easily by humans and machines, BSON’s binary format is machine readable only.

The binary encoding allows for faster parsing and easier traversal across large document structures. Because BSON is also type-linked and length-prefixed, systems can efficiently skip fields and jump directly to the data they need without scanning an entire document.

Advantages of BSON

BSON offers a number of advantages that make it well suited for modern applications and large-scale data handling, both in MongoDB and beyond.

  1. Compact storage: BSON requires less overhead than JSON while still being human-interpretable when converted. This helps minimize disk usage and optimize caching.

  2. Fast parsing: Its binary structure makes it faster to parse and traverse, particularly for large nested datasets.

  3. Extended data types: Developers get strong typing during data transmission, making BSON more precise and expressive than JSON in many scenarios.

  4. Validation-ready: Though it is technically schema-less, because BSON is structurally aligned with JSON, you can associate JSON Schemas with BSON documents to define rules for required fields, data types, value ranges, and nested object structures.

  5. Broad language support: With official libraries available for most major programming languages, BSON makes it straightforward to exchange data between services written in different environments.

Even though BSON is powerful, working with raw binary isn’t convenient. When you need to view or edit BSON, it’s helpful to have a tool that represents the data graphically. That’s where XMLSpy comes in.

Why a Graphical BSON Editor Helps

XMLSpy includes a visual BSON editor that displays the structure of the binary document in a grid format so you can immediately understand it and modify it as necessary.

The BSON grid view is interactive, and you can expand and collapse nested objects and arrays to view and understand the document structure at different levels. It’s also easy to add, delete, and move objects in the grid while the underlying binary code is updated in the background.

Content, too, can be edited easily in Grid View, enabled by in-cell commands in individual cells that allow type selection and offer other context-sensitive choices.

If a node is repeated, XMLSpy can present them in Table View, where the keys become column headers and each object appears as a numbered row instead of being listed one after another in the tree.

If validation is required – for instance, in MongoDB implementations – you can associate an existing JSON Schema with the BSON document in the XMLSpy Info Window.

How to Convert and Generate BSON

Beyond editing, XMLSpy lets you convert and generate BSON, bridging the gap between binary data and human-readable formats.

Common use cases include converting JSON or YAML data to BSON for MongoDB, or, conversely, transforming BSON to read or debug it in a more human-readable format. Support in XMLSpy includes:

  • Converting JSON ↔ BSON
  • Converting YAML ↔ BSON
  • Generating a BSON instance from an existing JSON Schema

If you don’t have a JSON Schema or need to edit an existing document, the graphical XML Schema editor in XMLSpy includes built-in support for assigning BSON datatypes for JSON objects, properties, and arrays.

If you're working with MongoDB, distributed applications, or data serialization pipelines, a visual BSON editor isn’t just a convenience—it’s a productivity multiplier. With built-in support for graphical BSON editing, conversion, and validation alongside full support for JSON and YAML, XMLSpy checks all the boxes.

You can try it free with a 30-day trial of XMLSpy.

And, if you need to further integrate BSON data in MongoDB with other systems like SQL databases, XML reports, or Shopify storefronts, check out the graphical data mapping tools in Altova MapForce.