When exploring MongoDB collections or analyzing schemas, you may stumble upon incorrect or wrong field types.
Maybe it’s just a mistake on a single document, or maybe it’s across all documents in your collection and you need to bulk-edit. Studio 3T allows you to quickly make these changes to MongoDB field types in just a few clicks, without needing to know the syntax for the $set operator.
Change the field type in a single document
In this example, we want to change the dob field type from string to date – but only in a single document.
Right-click on the field you want to edit and select Field > Edit Value / Type.

Under Type, select the new field type (for example, date).
Then, in Set this field in, select Current document only.

Click Set Value.
Bulk-edit a field type in all documents in a collection
In this example, we want to change the transactions field type which stores a customer’s total number of transactions from string to Int32 (32-bit integer) – but for all documents in the collection.
Right-click on any transactions value in the collection and select Field > Edit Value / Type.
In the Edit Value dialog, under Type, select Int32.
Then, in Set this field in, select All documents in collection.
Next, make sure to select Only change type (“Convert”).

Click Set Value.
Other field type editing options
Apart from editing a field type in the current MongoDB document or all documents, you can also change the field type in:
- documents matching query criteria (if you’re new to Studio 3T, you can set matching criteria for queries in Visual Query Builder)
- documents matching query criteria that have or don’t have a particular field
- all documents in collection that have or don’t have a particular field
Follow the same steps as mentioned above – and make sure to select Only change type when editing the documents.
This article was originally published by Kathryn Vargas and has since been updated.