Cloud Firestore, the NoSQL Database of the Google Cloud Computing world, makes some things harder than it should! One of them is exporting your data. The data already has a nested JSON-like structure, but there’s no way to export documents or collections to JSON via the Firebase Console. It’s not even possible to copy data from the web interface to the clipboard, you have to write custom scripts for these kind of things.
That’s one of the reasons we created Firefoo, a Firebase GUI client for your desktop that can export collections and documents to JSON files.
Step by Step Instructions
- Download and install Firefoo.
- If prompted, sign in with Google. This happens automatically if you have used the Firebase CLI on your machine.
- Right-click the collection in the sidebar and select Export Collection.
4. Make sure the JSON Format is selected and click the Export button.
5. Select the file destination in the file chooser.
6. That’s it!
Your collection is exported to JSON and a progress popup opens. If you close that popup, the export will still continue to run in the background. Get back to the progress popup again through File › Tasks.
By default, nested subcollections will be included automatically. You can prevent Firefoo from doing so by unselecting the Include Subcollections option. If you know that none of the documents contain subcollections, that’s what you should do, as it makes the export faster and saves you requests.
Export Firestore Query Results to JSON
You can export the results of a specific query with where and order-by clauses to JSON.
- Click the collection in the sidebar on the left.
- Add Where conditions and Order by clauses. Adjust the number of documents with the Limit field, click the Run button to run your query!
- Click the Export Results icon as seen in the screenshot below.
Export Subcollections to JSON
If you want to export a single subcollection to JSON, instead of one of the root-level collections, that’s also possible! Subcollections are not shown in the sidebar. That’s why you have to locate the subcollection in the Tree View (not the Table View) and open the right-click context menu from there. Choose Export and the same Export dialog as above appears.
How many requests will this take away from my quota?
Firefoo uses two read requests for every document that is exported. The first to fetch the data, the second to check for subcollections. If you unselect the Include Subcollections option, only one request is necessary, saving half of the total requests!
How to import the JSON Collections into Firestore?
Right-click on the target database in the sidebar and select Import Collections. In the Import Dialog, choose the JSON file and specify the target Collection name in the Target Path field.