Import CSV into Firebase Firestore

Import CSV into Firebase Firestore

Cloud Firestore makes some things harder than they should be! One of them is importing your data. There’s no way to import collections or documents using the Firebase Console. Previously you had to write a custom script that parsed the CSV file, iterated over the rows and created Firestore documents. Luckily now there’s Firefoo, the Firestore GUI that has CSV import built in!

Upload CSV as Firestore Collection using Firefoo

1
Download and install Firefoo
2
Right-click your project in the sidebar and choose Import Collections
3
Click on the Data File field and select your CSV file
default
5
Enter the collection name into the Target Path field
6
Click the Import button!
defaultYour collection is imported into Firestore and a progress popup opens. The import will continue to run in the background when you close that popup. Get back to the progress popup again through FileTasks.

Field Names

For every column in the original CSV data, you can specify the field name for the corresponding Firestore documents. These field names should not contain dots and it’s also best practice to not include special characters like spaces or slashes. By default, a camelCase version of the original CSV column name is suggested. Make sure that the Field Name values are all different from one another!

Import Options

☑️ convert types: When selected, Firefoo will attempt to automatically convert values from the CSV to their native Firestore types. This works with:
  • numbers: e.g. 42, -5.123
  • booleans: true, TRUE, false and FALSE
  • Timestamps: dates in ISO format, e.g. 2000–03–15T05:20:10+05:45
  • null values: null
  • arrays: e.g. ["abc","def"]
  • JSON: e.g. {a:"x", b:true, c:21, d:null, e:["x", 1, true]}
When you edit or view the CSV file with a text editor, quotes are escaped like this: "[""abc"",""def""]". Keep in mind that your JSON data must not include an array containing another array value as one of its elements, which is a Firestore limitation.
☑️ trim: When selected, Firefoo will remove any whitespace such as spaces or tabs before and after the content.
Document IDs: When auto-generate is selected, Firefoo will generate random 20-character strings (e.g. oXm520lZ3SAjDOWPW7Z1) as document IDs, just like in the Firebase Console. Select use column to use the values from a CSV column as document IDs. Make sure that the column contains unique values for every row, otherwise the documents will get overwritten. These values must follow the constraints on document IDs, most notably they must not contain slashes.

FAQ

Import CSV data into an existing Firestore collection

Instead of creating a new collection from the CSV data, it’s also possible to add the data into an existing collection. Right-click on the collection in the sidebar to do so and selectImport from there.
Make sure to adjust the Field Names in the field mapping table so that they match the structure of the existing documents in the collection. When you choose to use document IDs from a CSV column, and there‘s already a document existing with the same ID, the data will be merged, width imported fields overwriting existing fields.

Import CSV into a subcollection

To import the data from the CSV file as a subcollection into a document, specify the path to that subcollection in the Target Path field, e.g. /my_coll/my_doc/my_subcoll. This works for existing subcollections as well as to create new subcollections.

How many requests will this take away from my quota?

Firefoo uses exactly one write request for every row of your CSV file, as every row corresponds to one document.