Export and import JSON
Write documents to a file and create documents from a file.
- Step 1: Select rows and choose More, Export, or open the collection More options menu and choose Export Collection.
- Step 2: In Export Data, choose the Source: Selected Docs, Collection, or Query Results. Query Results ignores the limit and exports every match.
- Step 3: Set the batch size (1 to 500) and choose Export JSON.
- Step 4: Choose where to save the file. The default name starts with
firestore-and the collection name.
The file is a JSON array with one object per document. Timestamps, geopoints and references are written as markers (__time__, __geo__, __ref__) so an import restores the types. Integers above 2^53 keep their exact digits. A single document is exported from its row menu with Export Document.
Warning: Export does not include subcollections. If rows were loaded with Select or a reshaping pipeline, the file holds only the loaded fields, and the app warns you. A collection export runs as a background task. See Background tasks.
To import documents from a JSON file:
- Step 1: Open the collection More options menu and choose Import. A tab named Import with the collection opens.
- Step 2: Check Target (project and collection).
- Step 3: Under Source File, choose Click to select a JSON file. The file can be an array of objects or a single object.
- Step 4: Read the review: Total Docs, With Custom ID, Auto-ID, Unique Fields and the field list.
- Step 5: Set the Batch Size (up to 500) and choose the Import N Documents button.
Each object becomes a document. If an object has an id key, that is the document ID and it is not stored as a field. Without id, Firestore picks an automatic ID. To store a field named id, name it __id__ in the file. If two objects share an ID, the later one wins.
The app refuses files that are not JSON, that contain an item that is not an object, or that contain no documents, and names the problem. Files written by Export import back with their types intact.
Note: Import does not include subcollections. It runs as a background task, and Import Another File resets the page when it is done.