Export JSON from Firebase Firestore

Export JSON from Firebase Firestore

Cloud Firestore data 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 had to write custom scripts for these kinds 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 among others.

How to Export Firestore Collections as JSON

1
Download and install Firefoo
2
If prompted, sign in with Google
This happens automatically if you have used the Firebase CLI on your machine
3
Right-click the collection in the sidebar and select Export Collection
default
5
Make sure the JSON Format is selected and click the Export button
default
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 FileTasks. 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.
1
Click the collection in the sidebar on the left
2
Add Where conditions and Order by clauses. Adjust the number of documents with the Limit field, click the Run button to run your query!
3
Click the Export Results icon as seen in the screenshot below
default
5
Select the file destination in the file chooser
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.

JSON Structure

Firestore typeJSON representationExample
Array
[]
[1,2,"yellow"]
Boolean
boolean
false
Bytes
{
  "__datatype__": "bytes",
  "value": string
}
value is a base64 encoded Buffer
{
  "__datatype__": "bytes",
  "value": "AA//AA=="
}
Timestamp
{
  "__datatype__": "timestamp",
  "value": {
    "_seconds": number,
    "_nanoseconds": number
  }
}
_seconds is the unix timestamp as integer
{
  "__datatype__": "timestamp",
  "value": {
    "_seconds": 1636306475,
    "_nanoseconds": 1234000
  }
}
Double
number
64-bit double precision, IEEE 754
1337.42
Geopoint
{
"__datatype__": "geopoint",
  "value": {
    "_latitude": number,
    "_longitude": number
  }
}
_latitude and _longitude in degrees
{
  "__datatype__": "geopoint",
  "value": {
    "_latitude": 33.12321,
    "_longitude": 12.244411
  }
}
Integer
number
64bit signed
324375436234
Map
{}
json object with alphabetically-sorted keys
{
  "key1": "hello",
  "key2": true
}
Null
null
null
Doc Reference
{
  "__datatype__": "documentreference",
  "value": string
}
{
  "__datatype__": "documentreference",
  "value": "coll/docId/subColl/deepDocId"
}
String
string
"hello world"

Example Document JSON

{ "__id__": "JoelMacGyver", "address": { "city": "East Rozellaberg", "country": "Costa Rica", "street": "581 Yazmin Wells" }, "birthday": { "__datatype__": "timestamp", "value": { "_seconds": 452454895, "_nanoseconds": 0 } }, "devices": [ "iPhone", "PC" ], "firstName": "Joel", "height": 1.82, "jobTitle": "Regional Tactics Supervisor", "lastName": "MacGyver", "location": { "__datatype__": "geopoint", "value": { "_latitude": 23.512495615448177, "_longitude": 84.98532027801551 } } }

FAQ

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.