Home / Features / Bulk operations
Bulk operations
Bulk update Firestore fields safely, with a preview first
Set, rename or delete a field in every document a query matches. Firetool shows what will change before anything is written, writes in batches you can stop and resume, skips documents that changed in the meantime, and keeps copies you can restore.
The problem
A one-off migration script is easy to get wrong
Renaming phone to mobile, adding status: "active" to old records, or removing a field nobody uses: these jobs usually mean a throwaway script that reads everything, rewrites whole documents and hopes nobody else saved meanwhile. Firetool does the same jobs from the table. It writes only the one field, checks each document's version, and records every batch in the audit log.
Three field changes
From a column's ⋮ menu
Run a query, then open the ⋮ menu on a column's header. Three commands change that field across documents.
- Set a value in documents… writes one value, with a type you choose (Text, Number, True / false, Null, Timestamp, Reference or JSON). Tick Only documents that don't have this field yet to fill gaps without touching the rest.
- Rename field in documents… moves the value, with its type, to a new name. If a document already has the new name, leave it as it is or replace its value.
- Delete field from documents… removes the field and leaves the rest of each document alone.
Use dots for a field inside a map, such as address.town; the rest of the map is kept.
Which documents
The query you ran, or the rows you picked
Choose Every document matching this query or Selected rows. "This query" means the one from your last Run, not filters you've half typed since, so the job always matches the rows you looked at. The limit in the query bar doesn't cut it short: every matching document is read.
Before reading, Firetool counts the matches. Over 10,000 documents, it tells you how many reads that is and asks before going on.
Preview, then apply
See the change before it happens
Nothing changes until you choose Apply. Preview reads the documents and tells you how many will change out of how many matched, how many don't have the field, how many already have the value or the new name, how many writes it will take and how many documents the preview read. Up to five sample documents show the field before and after.
Pick the change
Open the column's ⋮ menu, choose Set, Rename or Delete, and fill in the field, name or value.
Preview
Check the counts and the before and after samples. Change anything and the preview is cleared.
Apply
The button names the job, such as Rename in 1,240 documents. Progress shows as it runs.
After Preview, Save the full list (CSV)… writes every document the change touches, with the field before and after (a rename as two rows), so you can check or keep the whole list before you apply. It counts as an export, so the project's export rules apply and the audit log records it.
How the writes are made
Small, checked writes that you can stop
Only the field
Each write names just that field in its update mask. Other fields, including ones changed by someone else, are left as they are.
Version check
Each write carries the document's update time from the preview. A document changed or deleted since then is skipped and counted, and Preview again picks it up.
Batches of 500
Writes go to Firestore 500 at a time. Writes refused only because Firestore was busy are sent again with a pause between tries.
Stop and resume
Cancel stops after the current batch. Resume carries on from there, and an error stops the job the same way. In Tools, Tasks you can also pause the job and see the time left.
Restorable copies
Before each batch, Firetool keeps a copy of the documents it changes in the audit log, unless your policy is set to keep nothing. On a project marked production, a copy of every changed document is kept by default. Undo… in Tasks puts the whole job back in one go. Undo an operation
Clear results
At the end you see how many changed, how many were skipped because they changed after the preview, and how many failed.
Production projects
One more check where it matters
Mark a project or one of its databases as production in Project settings, and any write that changes more than one document asks you to type the project ID first, once per job. Your policy can also ask for a reason, saved in the audit log with the change. A project or database marked read-only can't be changed at all, and Viewers can't run field changes.
- Policy and roles can cap how many documents one delete may remove
- Every batch, and every refused attempt, is recorded in the hash-chained audit log

Other bulk jobs
Scripts, selected rows and whole collections
When the change depends on other fields, write it in JS Query with db.batch(), which takes up to 500 writes per commit. Script writes pass the same checks: roles, read-only and production marks, the delete limit and the audit log. By default, copies are kept for documents a script deletes or removes fields from, not for its other updates; set the policy's copies to Everything that changes to keep those too.
- Select rows in the table and Delete them together, in batches of 500
- Right-click a collection, Delete collection…: it counts the documents, asks you to type the collection name, deletes them and their subcollections in batches of 500, and can be stopped and resumed
// Mark inactive customers for review
const snap = await db.collection("customers")
.where("status", "==", "Inactive")
.get();
const batch = db.batch();
snap.forEach(doc => batch.update(doc.ref, {
reviewedAt: FieldValue.serverTimestamp()
}));
await batch.commit();
return `Updated ${snap.size} documents`;Bulk field changes, deletes and JS Query need Firetool Pro. In the Free edition the field commands show in the column menu but are turned off.
Questions
Bulk field changes: common questions
How do I add a field to every document in a Firestore collection?
Open the collection, run the query without filters, and choose Set a value in documents… from any column's ⋮ menu. Type the new field name, its type and value, and tick Only documents that don't have this field yet if existing values should stay. Preview, then Apply.
What if someone edits a document while the job is running?
That document's write is refused by Firestore, because its update time no longer matches the preview, and Firetool counts it as skipped. Their edit stays. Preview again to include it with its new data.
Can I undo a bulk rename or delete?
Yes, unless your policy keeps no copies. Choose Undo… on the finished job in Tasks, or Undo this operation… on any of its entries in the audit log. One preview says how many documents go back as they were before the job and which, if any, can't be undone because no copy was kept; the undo then runs as a job of its own, through the usual checks. Restore on a single entry still puts back just that batch.
Does a rename keep the field's type?
Yes. The stored value moves to the new name exactly as it was, whether it's a timestamp, a 64-bit integer, a map or anything else.
More changes
Beyond setting a value
Add a number
Add to (or subtract from) a number field in every matching document; whole numbers stay exact, however large.
Convert a type
Text "42" to a number, numbers to text, dates to timestamps, yes/no to true/false; values that can't be converted are counted and left alone.
A new ID in each document
A random UUID as text, in every document or only where the field is missing.
Find and replace text
Replace every occurrence of a word in a field, matching case or not, with the exact results in the preview.
Save it, run it again
Save a change with its query and run it on staging first, then production, with the same preview and checks. Saved changes
Export as a script
Turn a saved change into a Node.js Admin SDK script that shows what would change unless you run it with --apply. Its changes don't go through Firetool's checks.
Know the cost first
A large job shows its estimated cost, from list prices for the database's location or your own prices.
Related
More you can do with Firetool
Try it on your own data
Free for Windows, macOS and Linux, with every Pro feature for the first 30 days.