> For the complete MongoDB documentation index, see www.mongodb.com/docs/llms.txt

<!--
Tab options on this page. Append to the .md URL to filter:
  ?tabs=<id,...>   select specific tabs (e.g. ?tabs=nodejs,shell)
  ?allTabs=true    include every tab
  (no param)       default: one tab per tabset

Available tabs:
  other tabs: shell-syntax, field-by-field, json
-->

# Insert Documents

MongoDB Compass Readonly Edition will be deprecated in a future release. To replicate the read-only behavior in a standard Compass edition, assign users [`read`](https://www.mongodb.com/docs/manual/reference/built-in-roles.md#mongodb-authrole-read) access at the database level and enable the [readOnly](https://www.mongodb.com/docs/compass/settings/read-only.md#std-label-compass-read-only) option in Compass.

**Important:**

Inserting documents is not permitted in MongoDB Compass Readonly Edition.

Compass provides the following view modes to insert documents into your collections:

Shell Syntax Mode

Write or paste documents in the MongoDB shell syntax, which allows unquoted field names and type constructors such as `ObjectId()` and `ISODate()`. Use this mode to insert multiple documents at once as an array.

Field-by-Field Editor

Select individual field values and types for each inserted document. This mode only supports inserting one document at a time.

JSON Mode

Write or paste documents in [Extended JSON](https://www.mongodb.com/docs/manual/reference/mongodb-extended-json/) format, which requires quoted field names and represents BSON types as wrappers such as `{"$oid": "..."}`. Use this mode to insert multiple documents at once as an array.

## Procedure

To insert documents into your collection, select the tab corresponding to your chosen view mode:

### Shell Syntax Mode

1. Open the Add Data drop-down menu.

   In the drop-down menu, click Insert Document.

   ![Insert button](/images/compass/insert-button.svg)

   Alternatively, you can right-click the query bar or its surrounding whitespace and select Insert document... from the drop-down menu.

2. Open the editor in Shell Syntax mode.

   In the Insert Document modal, click the  icon to use Shell Syntax mode to insert documents into your collection.

   Shell Syntax mode is the default view.

3. Insert your documents.

   In the MongoDB shell syntax, type or paste the document(s) you want to insert into the collection. To insert multiple documents, enter a comma-separated array of documents.

   **Example:**

   The following example inserts a single document into the collection. Field names are unquoted, and the `_id`, `copies`, and `lastCheckedOut` values use the `ObjectId()`, `NumberInt()`, and `ISODate()` type constructors instead of Extended JSON type wrappers:

   ```javascript
   {
     _id: ObjectId('507f1f77bcf86cd799439011'),
     title: 'The Odyssey',
     author: 'Homer',
     copies: NumberInt('10'),
     lastCheckedOut: ISODate('2025-03-14T09:30:00Z')
   }
   ```

   **Note:**

   If you do not specify an `_id` value in your document, Compass automatically generates an [ObjectId](https://www.mongodb.com/docs/manual/reference/bson-types.md#std-label-objectid) for the `_id` field.

4. Click Insert.
