-
Type:
Bug
-
Resolution: Works as Designed
-
Priority:
Blocker - P1
-
Affects Version/s: 1.49.14
-
Component/s: None
-
None
-
Environment:OS: Windows 11 Enterprise
node.js / npm versions:
PS C:\Users\me> node -v; npm -v
v25.8.2
11.11.1
-
Not Needed
-
None
-
Developer Tools
-
-
- *Problem Statement/Rationale*
-
When I copy a document from MongoDB Compass using the *Copy to clipboard* button, Compass returns MongoDB shell-style syntax instead of valid JSON.
The copied content includes unquoted field names, single-quoted strings, and MongoDB shell constructors such as `ObjectId()`, `NumberLong()`, and `ISODate()`. As a result, the content cannot be formatted or parsed by a standard JSON formatter, despite being copied from a file/document view labeled as JSON.
This appears to affect the generic *Copy to clipboard* action. Compass export output using MongoDB Extended JSON formats correctly.
*Compass version:* `[insert version from Help > About]`
*Operating system:* Windows
*MongoDB deployment:* `[Atlas/local/other, if relevant]`
No sensitive data is included in the example below. Any attached logs have been redacted.
-
-
- *Steps to Reproduce*
-
1. Open MongoDB Compass.
2. Open a collection containing a document with BSON-specific values such as an ObjectId, Long, and Date.
3. Open the document view.
4. Click the *Copy to clipboard* button.
5. Paste the result into a `.json` file or a standard JSON formatter/parser.
Example of the copied output:
```js
{
_id: ObjectId('68537061de9912c4a089e6dd'),
displayName:
,
version: NumberLong('1'),
createTimestamp: ISODate('2026-08-12T11:42:19.841Z')
}
```
-
-
- *Expected Results*
-
The *Copy to clipboard* action should produce valid JSON, preferably MongoDB Extended JSON so BSON types are preserved:
```json
{
"_id":
,
"version":
,
"createTimestamp":
}
```
At minimum, the copy action should clearly identify that it is copying MongoDB shell syntax rather than JSON. Ideally, the copy behavior should be consistent with Compass’s JSON export behavior.
-
-
- *Actual Results*
-
The copied document is MongoDB shell-style JavaScript/BSON syntax, not valid JSON:
- Field names are not quoted.
- Strings use single quotes.
- `ObjectId()`, `NumberLong()`, and `ISODate()` are used instead of JSON representations.
- The copied content cannot be parsed or formatted by standard JSON tools in VS Code.
- The tooltip only says *Copy to clipboard*, so it is unclear that the output is not JSON.
For comparison, a document exported from Compass as Extended JSON is valid JSON and formats correctly:
```json
{
"_id":
,
"version":
,
"createTimestamp":
}
```
-
-
- *Additional Notes*
-
This may be a recent change in the serialization behavior of the copy button, or the copy action may be using a different serialization mode from the JSON export action. The issue is reproducible on the latest installed Compass version, although the exact version should be included above.
The generic copy action and the Extended JSON export action produce different formats for the same type of document:
- *Copy to clipboard:* MongoDB shell syntax, not valid JSON.
- *Export as Extended JSON:* Valid JSON with BSON type wrappers.
Relevant logs should be attached separately after reviewing and redacting any connection strings, usernames, hostnames, database names, document contents, or other sensitive information.
—