Processed in your browser

JSON / BSON Converter

Uses the BSON library to preserve ObjectId, dates, and long integers. Binary BSON is represented as Base64, and decoding emits explicit MongoDB Extended JSON markers.

Processed in your browser
0 / 1,500,000
Converted output

Tool guide

What is JSON / BSON Converter?

JSON and BSON Converter supports MongoDB document and driver debugging. Ordinary or Extended JSON root documents encode to Base64 BSON, and decoded bytes return explicit Extended JSON so ObjectId, dates, decimals, and long integers are not forced into misleading ordinary values. Common workflows include the following. Generate BSON document bytes for MongoDB driver tests. Decode BSON Base64 found in an API or log. Inspect Extended JSON for ObjectId, dates, and long integers. The page also documents input boundaries, output behavior, and practical cautions so you can review the result before putting it into an application, configuration, test, or production workflow.

When to use it

  • Generate BSON document bytes for MongoDB driver tests.
  • Decode BSON Base64 found in an API or log.
  • Inspect Extended JSON for ObjectId, dates, and long integers.

How to use it

  1. Use an ordinary or Extended JSON root object when encoding.
  2. Paste complete BSON Base64 when decoding.
  3. Convert and inspect Extended JSON markers.
  4. Review compatibility with the target driver version.
  5. Load one of the realistic examples first to verify the selected options and processing direction before replacing it with your own data.
  6. Review the output, status message, and documented limits; copy, download, or continue only after the result matches your expectation.

Runnable examples

The “Example 1” and “Example 2” buttons load the matching inputs. They cover different structures, directions, or boundaries and can be run directly in the workspace.

Example 1

{"_id":{"$oid":"64b64c3f2f4e4e6f1a2b3c4d"},"count":{"$numberLong":"9007199254740993"},"createdAt":{"$date":"2026-08-09T00:00:00Z"}}

Example 2

JwAAAAdfaWQAZLZMPy9OTm8aKzxNABJjb3VudAAJAAAAAAAAAA==

Input rules

  • Encoding input must be a root document object.
  • BSON-specific values should use valid Extended JSON markers.
  • Decoding requires complete standard Base64 BSON bytes.
  • Text input is counted before processing and is limited to 1,500,000 characters on this page; file modes apply the separate file limit shown in the workspace.
  • BSON requires a root document object.

Output rules

  • Binary BSON is displayed as Base64.
  • Decoded values use canonical Extended JSON markers.
  • Ordinary JSON consumers may not understand $oid, $date, or $numberLong.
  • Output reflects only the current input, direction, and options; rerun after changing a mode or value instead of treating an earlier result as current.
  • Binary output is represented as Base64.

Limitations and cautions

  • BSON requires a root document object.
  • Binary output is represented as Base64.
  • BSON-specific types use MongoDB Extended JSON rather than ordinary JSON values.

How your data is handled

All parsing, conversion, binary encoding, and intermediate data remain in the current browser tab. JSONLane does not upload the input or retain it after refresh or close.

FAQ

Is BSON content uploaded?

No. Parsing, conversion, and output generation remain in the current browser tab.

Is every round trip lossless?

No. Formats differ in types, comments, ordering, and binary capabilities; the page documents the important losses.

Why are some inputs rejected?

Unsafe integers, dangerous keys, excessive depth, and values with no clear target representation are rejected instead of silently rewritten.

Can ordinary JSON be encoded as BSON?

Yes. Use MongoDB Extended JSON markers when ObjectId, dates, long integers, or other BSON-specific types must be preserved.

Why does a long integer use $numberLong?

That marker preserves an exact integer beyond JavaScript's safe numeric range inside JSON text.

Can the Base64 be pasted directly into MongoDB?

Usually not. Drivers and wire protocols expect raw BSON bytes, so the Base64 carrier must be decoded first.

Updated: 2026-08-09