Firetool

Home / Docs / The firetool command

Docs

Query and change Firestore from the terminal

The firetool command is Firetool without its window. It uses the same accounts, roles, project rules and audit log as the app, so you can read data in a script, export it on a schedule or check it in CI.

Reading works in the Free edition and needs no licence. Changing data (set, update, delete, export, import and changing users) needs Pro on that computer, as in the app.

Set it up

The command comes with Firetool from the download page; there's nothing else to install. In Firetool, choose Help → Use Firetool from the terminal…: it shows where the command is on your computer and the one command that puts it on your PATH, with a button to copy it.

SystemWhere it isTo use it anywhere
Windowsbin\firetool.cmd in Firetool's program folder (usually %LOCALAPPDATA%\Programs\Firetool)Run the PowerShell line Help → Use Firetool from the terminal… gives you once, then open a new terminal.
macOSInside the app: Firetool.app/Contents/Resources/bin/firetoolThe installer links it when it can; otherwise it shows this command to run once: sudo ln -sf "/Applications/Firetool.app/Contents/Resources/bin/firetool" /usr/local/bin/firetool
Linuxfiretool (the .deb and the .tar.gz install it)Nothing to do.

Check it works:

firetool version
firetool help

The command uses the accounts you added in Firetool, and it works while Firetool is open.

Read data

# The accounts added in Firetool, and the projects of one
firetool accounts
firetool projects

# A project's databases, its top-level collections, and those under a document
firetool databases shop-production
firetool collections shop-production
firetool collections shop-production users/alice

# One document
firetool get shop-production users/alice

# Documents that match, sorted, at most 20
firetool query shop-production orders --where "status == paid" --where "total >= 100" --order "total desc" --limit 20

# Every collection called orders (a collection group)
firetool query shop-production orders --group --where "status == refunded"

# How many documents match (one read per 1,000 counted)
firetool count shop-production orders --where "status == paid"

# Problems in the documents that match (4.2): duplicate emails, references to missing documents, mixed types
firetool check shop-production customers --duplicates email --references '*' --types

# Authentication users
firetool users list shop-production --limit 50
firetool users get shop-production ada@example.com

--where takes "<field> <op> <value>", where op is one of == != < <= > >= in not-in array-contains array-contains-any starts-with. Numbers, true / false and null are read as such; put text that looks like a number in quotes ("pin == '007'"). Lists are a,b,c or ["a","b"]. query reads 50 documents unless you give --limit (up to 10,000).

check (4.2) looks for problems in the documents that match: --duplicates <field> (values shared by several documents), --references <field> or '*' for every reference field (references to documents that don't exist; one read per referenced document) and --types (fields stored with more than one type). It checks 10,000 documents unless you give --limit (0 for every matching document; more than 10,000 reads needs --yes), prints what it found (or --json) and ends with exit code 6 when it finds problems. See Check data.

Output for scripts

The command prints tables for people. Add --json for scripts; query also takes --format jsonl (one document per line) or --format csv.

firetool query shop-production orders --where "status == paid" --json
firetool query shop-production orders --format csv > orders.csv

JSON keeps exact values in Firetool's form, such as {"$timestamp": "2026-01-01T00:00:00Z"}, so nothing loses its type.

Backups, schemas and rules

Four more commands for scheduled jobs and CI. They use the same routes as the window, so the roles, project rules and audit log apply to them too.

# Every document of a project (or one collection and what is under it) into one compressed file
firetool backup shop-production --out backups/shop-2026-10-05.json.gz
firetool backup shop-production --collection orders --out orders.json.gz

# Put a backup's documents back (from Firetool or from firetool backup); count first, keep what is there
firetool restore shop-staging --file backups/shop-2026-10-05.json.gz --dry-run
firetool restore shop-staging --file backups/shop-2026-10-05.json.gz --skip-existing

# Put back only some collections and documents: compare first, then write only what's missing or different
firetool restore shop-production --file backups/shop-2026-10-05.json.gz --only orders/1001,users/*/orders --preview
firetool restore shop-production --file backups/shop-2026-10-05.json.gz --only orders/1001,users/*/orders --confirm shop-production

# Write down what a collection's documents look like, then check documents against it later
firetool schema infer shop-production orders --out orders.schema.json
firetool schema check shop-production orders --schema orders.schema.json

# Try requests against the project's security rules (or a rules file) before you deploy
firetool rules test shop-production --file rule-cases.json
firetool rules test shop-production --file rule-cases.json --rules-file firestore.rules

backup reads every document through the same checks as an export and writes a file Firetool's Restore also opens. It holds documents only: add Authentication users, rules and indexes from the app's backup dialog. restore points references into the backed-up database at the one it restores into, and with --with users,rules,indexes (or --with all) it also restores those parts of a backup made in the app: users that already exist are kept, only missing indexes are made, and the rules replace the live ones only when they differ. --dry-run says what each part would do. --only takes collections (with what is under them; * stands for any document ID, as in users/*/orders) and documents, separated by commas: each chosen document is compared with the project now (one read each), only the missing and different ones are written, one edited since the comparison is skipped, and each batch is read back. --preview does the comparison and writes nothing. --only restores documents only, so it can't be used with --with. The whole restore is one operation, so Undo this operation in the app's audit log takes it back. restore writes, so it asks for the same confirmations as any other change (--confirm for a production project, --reason where your policy asks). See Backup and restore.

schema infer reads up to 10,000 documents (--limit, 0 for every document) and writes the fields, their types and which ones every document has, in the file the Schema tab keeps. schema check lists documents with a missing field, a field of another type or a field the schema doesn't know, and ends with exit code 6 when it finds any. Keep the schema file in your repository and the check becomes a step that fails when the data drifts. See Schema.

rules test sends each request in the file to the Rules API and compares the answer with what you expect. Nothing is deployed and nothing is written. The file is a list such as:

[
  { "name": "A user reads their own profile", "method": "get", "path": "users/alice", "auth": { "uid": "alice" }, "allow": true },
  { "name": "A user can't read another profile", "method": "get", "path": "users/bob", "auth": { "uid": "alice" }, "allow": false },
  { "name": "Signed out users can't write", "method": "create", "path": "orders/new", "data": { "total": 10 }, "allow": false }
]

method is get, list, create, update or delete; data is the document after a create or update, and existing the document as it is now. allow is true unless you say otherwise. Add --service storage --target <bucket> for Storage rules. The result lists PASS or FAIL for each request, and exit code 6 means at least one got a different answer than expected. See Security rules.

Compare and copy environments

New in 4.5.1. A and B are each a project, or project/database, such as shop-staging shop-production.

# Every collection of two databases, document by document with subcollections (reads only)
firetool compare shop-staging shop-production
firetool compare shop-staging shop-production --collection orders

# Indexes: list, compare, and create in B what only A has (Pro)
firetool indexes list shop-production
firetool indexes fields shop-production
firetool indexes diff shop-staging shop-production
firetool indexes apply shop-staging shop-production --dry-run

# Copy what's missing or different in B (Pro); --dry-run lists it first
firetool transfer shop-staging shop-production --dry-run
firetool transfer shop-staging shop-production --confirm shop-production

compare counts each collection on both sides, then reads the collections both have page by page and lists what's only in A, only in B and different, with the fields. It only reads, works in the Free edition, and asks for --yes over 10,000 documents. compare and indexes diff end with exit code 6 when the two differ, so a CI step can stop on drift.

indexes apply creates in B only the indexes A has and B lacks, and never deletes one. It also sets B's single-field settings as A has them; it turns a TTL policy on only with --confirm <B's project> (on any project: Google then deletes expired documents) and never turns one off. indexes fields lists a database's field settings and TTL policies. transfer writes only documents missing in B or different there (references pointed at B), each only while B's copy is still the one it read, and never deletes anything in B; --skip-existing keeps B's different documents. Its --dry-run only reads, so it works in the Free edition too. The copy-out and masking rules apply as in the window, production asks for --confirm, and the whole transfer is one operation in the audit log, so Undo this operation takes it back. See Compare and migrate environments.

Functions, logs, Hosting and services (Pro)

New in 4.5.2. These only read, and need Pro on that computer.

# A project's Cloud Functions, 1st and 2nd gen (variable names only, never values)
firetool functions list shop-production

# Log entries, newest first; masked unless --unmasked
firetool logs shop-production "payment failed" --since 1h --severity ERROR
firetool logs shop-production --source functions --name onOrderPaid --since 24h --format jsonl

# Hosting releases of the default site, or another one
firetool hosting releases shop-production --site shop-production-blog

# Compare the services of two projects (exit code 6 on differences)
firetool compare shop-staging shop-production --with functions,hosting,pubsub,queues,remoteconfig,storage
firetool compare shop-staging shop-production --with all

logs takes --since and --until (30m, 1h, 24h, 7d or a time), --severity (that level and above), --source (functions, run, firestore, hosting, tasks, scheduler or pubsub) with --name, --limit and --format table|json|jsonl|csv. Email addresses, phone numbers, tokens and keys are masked unless you add --unmasked. compare --with compares only the services you name (storage, from 4.5.5, compares every bucket's settings; Google's own buckets are left out); add documents, or use all, for the databases too. Each project's own ID is ignored, so shop-staging's site lines up with shop-production's. See Functions, logs and other services.

The team's shared file (Pro)

For team sharing: read and check the team's shared file, and merge two versions of it.

# The items in the file chosen in Settings → Team (or --file <path>)
firetool shared list
firetool shared list --file firetool-shared.json --json

# Whether every item can be used here; exit code 6 when one can't (a CI step)
firetool shared check --file firetool-shared.json

# Two versions as one (into the first, or --out)
firetool shared merge ours.json theirs.json --out merged.json

In a git repository, firetool-shared.json merge=firetool in .gitattributes and git config merge.firetool.driver "firetool shared merge %A %B" let git merge the file the way Firetool does: the newer version of an item wins, and two edits of the same version are both kept.

Change data (Pro)

# Write a whole document, or change only some fields of one that exists
firetool set shop-staging settings/app --data '{"maintenance": false, "version": 3}'
firetool update shop-staging users/alice --data '{"plan": "pro"}'
firetool update shop-staging users/alice --file alice.json

# Delete one document
firetool delete shop-staging users/test-user --yes

# Export what matches to a file (.json, .jsonl or .csv), and import it again
firetool export shop-production orders --where "status == paid" --out paid-orders.jsonl
firetool import shop-staging orders --file paid-orders.jsonl --skip-existing

# Users
firetool users disable shop-production uid1 uid2
firetool users enable shop-production uid1
firetool users delete shop-staging uid3 --yes

# Import users from Firetool's Export CSV or the Firebase CLI's auth:export file
firetool users import shop-staging --file users.json --dry-run
firetool users import shop-staging --file users.json --hash-from shop-production
firetool users import shop-staging --file users.csv --hash-algo SCRYPT --salt-separator Bw== --rounds 8 --mem-cost 14

users import (from 4.5.4) checks every row first: rows with a bad email or phone number, broken custom claims, or the same UID, email or phone twice are listed and left out, and users that already exist are skipped. Passwords come along only with the hash settings they were made with: --hash-from <project> uses a project's own (read in the background, never printed), or --hash-algo with --hash-key, --salt-separator, --rounds and --mem-cost as the Firebase CLI's auth:import takes them. Put the key in the FIRETOOL_HASH_KEY environment variable instead of --hash-key to keep it out of your shell history; it's never saved or logged. --dry-run only checks the file, with exit code 6 when rows have problems.

--data and --file use Firetool's JSON form, so types are kept ({"at": {"$timestamp": "2026-01-01T00:00:00Z"}}). import reads what export writes; --skip-existing keeps documents that are already there. Add --dry-run to set, update, delete, import or a user change to see what would change without writing anything: it reads the first 50 documents or users it would touch (one read each) and prints each field now → after, the ones that wouldn't change, and writes Firestore would refuse, such as an update of a document that isn't there. With --json you get writes, changes, unchanged and refused.

Every change goes through the same checks as the window: your role, read-only and production projects, protected collections, and the audit log, where it's marked as coming from the terminal.

Confirmations

Where the window would ask you something, the terminal can't, so the command stops with exit code 4 and tells you which option answers it. Run it again with that option:

  • --confirm <project-id>: the project is marked production and the change needs its project ID typed. From 4.5.5 it also unlocks a project or database that's locked until unlocked (see Environment rules), for that one command only.
  • --reason "…": your policy asks for a reason (from 4.5.5, a project or database labelled Production does by default). It goes in the audit log.
  • --yes: deleting, or reading more than 10,000 documents.
firetool delete shop-production users/old-test --yes --confirm shop-production --reason "Removing a test account"

Options

OptionWhat it does
--account <id or name>Which account to use, when several can open the project.
--db <database>A database other than (default).
--jsonMachine-readable output.
--format table|json|jsonl|csvFor query, how to print; for export, the file's format (otherwise from the file name).
--where, --orderFilters and sorting; both can be repeated. --order "total desc".
--limit <n>At most n documents (query: 50 by default) or users (100 by default).
--groupEvery collection with that name (query, count, check, export).
--duplicates, --references, --typesWhat check looks for; the first two can be repeated.
--data, --fileThe fields for set and update; the documents for import.
--out <path>The file export, backup or schema infer writes.
--collection <name>Backup, compare, transfer: only this collection and what is under it.
--with <parts>Restore: users, rules, indexes or all, separated by commas.
--only <paths>, --previewRestore: only these collections and documents, separated by commas (* for any document ID); --preview compares them with the project and writes nothing.
--hash-algo, --hash-key, --hash-fromUsers import: the hash settings the passwords were made with (also --salt-separator, --rounds, --mem-cost), or a project whose own settings to use. FIRETOOL_HASH_KEY can hold the key.
--schema <path>Schema check: the schema file from schema infer.
--rules-file, --service, --targetRules test: rules from a file instead of the live ones, firestore (default) or storage, and the database or bucket.
--skip-existingImport, restore or transfer: keep documents that already exist.
--confirm, --reason, --yesAnswers to the window's questions (above).
--dry-runWrite nothing. Set, update, delete, import and users: what would change, now → after. Indexes apply: the indexes it would create. Transfer: what it would copy. Restore: the documents counted and what each --with part would do.
--key-file <path>A service account key for this run only (below).

Exit codes

CodeMeaning
0Done.
1Failed (the message says why).
2Wrong usage: a missing argument or an option it doesn't know.
3Needs Firetool Pro.
4Needs a confirmation: run it again with the option it names.
5Refused by the rules: your role, a read-only project or a protected collection.
6check, schema check or shared check found problems, or rules test got an answer you didn't expect (so a CI step fails).

CI and servers

On a build server there are no Firetool accounts, so give the command a service account key for the run:

  • --key-file key.json, or the file's path in FIRETOOL_KEY_FILE, or
  • the key's JSON itself in FIRETOOL_KEY, which suits a CI secret.

The key is used for that run only: it's used by default, never saved and never printed. On Linux without a display, the command runs headless. Reading needs no licence; changing data needs Pro on that machine.

On Linux the command needs no display: it runs on servers, in containers and on CI runners, as root or as an ordinary user.

Firetool has to be installed on the runner from the Linux .deb or .tar.gz you download from firetool.in. For example, keep the installer where your runner can reach it, then:

name: Firestore checks
on:
  schedule:
    - cron: "0 6 * * *"
jobs:
  checks:
    runs-on: ubuntu-latest
    env:
      FIRETOOL_KEY: ${{ secrets.FIRETOOL_KEY }}
    steps:
      - uses: actions/checkout@v4
      # The Firetool installer, downloaded from firetool.in and kept in the repository
      - name: Install Firetool
        run: sudo apt-get install -y ./ci/Firetool-linux-x64.deb
      # Each of these ends with exit code 6 when it finds a problem, which fails the job
      - name: Data has no duplicates or broken references
        run: firetool check shop-staging customers --duplicates email --references '*' --types
      - name: Orders still match their schema
        run: firetool schema check shop-staging orders --schema schemas/orders.schema.json
      - name: Security rules answer as expected
        run: firetool rules test shop-staging --file schemas/rule-cases.json --rules-file firestore.rules
      - name: Back up the orders
        run: firetool backup shop-staging --collection orders --out orders-backup.json.gz
      - uses: actions/upload-artifact@v4
        with:
          name: orders-backup
          path: orders-backup.json.gz
          retention-days: 14

A backup file holds your data: keep it somewhere only your team can read, as the artifact above is for a private repository, and give it a retention period you are happy with.

Give the service account only the roles it needs, such as Cloud Datastore Viewer for a job that only reads (check, schema and backup); rules test also needs permission to test rules in Firebase. The project rules you set in Firetool on that machine still apply.

Questions

Does the command need Firetool to be closed?

No. It works while Firetool is open, with the same accounts.

Do changes from the terminal go in the audit log?

Yes. Every change goes through the same checkpoint as the window and is recorded in the audit log, marked as coming from the terminal.

Is the key I give in CI kept anywhere?

No. A key from --key-file, FIRETOOL_KEY_FILE or FIRETOOL_KEY is used for that run only. It isn't saved with Firetool's accounts and isn't printed.