Firetool

Home / Features / Firestore query tool

Query tool

A Firestore query tool with every operator, and JavaScript when you need more

Filter and sort any collection from a query bar, combine filters with AND or OR, and count or add up everything a query matches without loading it. When a filter isn't enough, write an Admin SDK-style script and see the result as a table.

Two ways to ask

A query bar for everyday questions, scripts for the rest

Each collection opens in its own tab with a query bar on top. Simple mode builds a real Firestore query from a few fields: which collection, which filters, which order and how many documents. JS Query mode, in Firetool Pro, runs a script written the way you would with the Firebase Admin SDK. Both send the query to Firestore itself, so what you see is what your app would get, including the index rules Firestore applies.

Simple mode

Filters, sorts and a limit, without code

Type a collection path (collections and document IDs are suggested as you type), then add a line with Filter or Sort. Each filter has a field, an operator, a value and a type. Field names and common values are suggested from the documents you've loaded, and the type is guessed from the data, so a number stored as text is sent as text.

  • Match all filters (AND) or Match any filter (OR)
  • Sort by one or more fields, ascending or descending
  • Limit from 1 to 10,000 documents, then Load more for the next page
  • Tick Group to search every collection with that name at any depth
  • Enter or Ctrl+Enter runs the query
Firetool's query bar filtering a customers collection where plan is in Pro or Team, sorted by lifetime value

Operators

Every Firestore operator in the query bar

OperatorMatches documents where the field
== !=equals, or doesn't equal, the value
< <= > >=is before or after the value: numbers, text, timestamps
array-containsis an array holding the value
array-contains-anyis an array holding at least one of the values
in not-inequals one of the values, or none of them
is null is not nullis null, or has a value that isn't null

For the list operators, type the values separated by commas (Pro, Team) or as a JSON array. Value types are Auto, String, Number, Boolean, Timestamp, Reference, Null and JSON.

Around the query

The parts that save you reads and time

Σ Totals

Count the documents a query matches, or the sum or average of a number field, worked out by Firestore without loading the documents. Free in every edition.

Saved queries

Save (the star in the query bar) keeps a query, with its filters and sorts, in the sidebar on this computer. Saved scripts never run by themselves: you press Run.

Live refresh

Run a query again every 15 seconds, 30 seconds, minute or 5 minutes. New rows flash green and changed rows amber. Each refresh is billed as reads. On an emulator project, where reads cost nothing, Live can also refresh every second, 2 or 5 seconds.

Index helper

When Firestore says a query needs a composite index, choose Create the index for this query… and the index form opens already filled in.

Project and database picker

Move a tab's query to another project, account or named database and run it there, without typing it again.

Quick filters from the table

Right-click a cell to filter by that value (== or !=), or use a column's ⋮ menu to sort the query by it or show only documents that have it.

JS Query (Pro)

Admin SDK-style scripts, with results as a table

Switch the tab to JS Query and write JavaScript with db, auth, FieldValue, Timestamp and Filter. Return the result of .get() or document snapshots to see a table; return anything else to see it as JSON. console.log output appears under the script.

  • where, Filter.or and Filter.and, orderBy, limit and limitToLast, offset, select
  • Cursors: startAt, startAfter, endAt, endBefore
  • Transactions, batches and FieldValue (server timestamp, increment, array union and remove, delete)
  • count() and aggregate(), findNearest() vector search and explain()
  • Firebase Authentication through auth.*, such as getUserByEmail and listUsers
  • An Examples menu with ready scripts to start from
  • Colours in the editor, TypeScript (types are taken out before the script runs; no type checking) and ⟲ History of your last 30 scripts
A JS Query in Firetool that totals orders by status, with the result shown as JSON
// Pro or trial customers in Pune, highest value first
return db.collection("customers")
  .where(Filter.or(
    Filter.where("plan", "==", "Pro"),
    Filter.where("trial", "==", true)
  ))
  .where("address.city", "==", "Pune")
  .orderBy("lifetimeValue", "desc")
  .limit(100)
  .get();

Safe by design

Scripts run in their own process

A script runs in a separate process that has no credentials, can read only Firetool's own script code, can't write files, can't start other programs and can't use the network. Every request it makes comes back to Firetool, where it is checked like any other change: your role, read-only and production marks, and the audit log. A project marked production asks for its project ID before a script runs, and a script that runs longer than 10 minutes is stopped. You can also stop it yourself with Stop.

Not sure what a script will change? Dry run, beside Run, runs it with its writes held back and lists every document it would create, update or delete, with each field now and after. Apply then writes exactly those changes as one job you can undo, and skips any document that changed since. Dry run a script

How it works

From question to answer

Open a collection

Pick it in the sidebar, or tick Group to search a collection group.

Add filters and sorts

Choose operators and types, and Match all or Match any. Use Σ Totals to count first.

Run and keep it

See the rows as a table, tree or JSON, then save the query or turn on Live.

Questions

Querying Firestore: common questions

Can I combine Firestore filters with OR?

Yes. With two or more filters in the query bar, choose Match any filter and the query matches documents that meet at least one of them. + Group adds a group with its own Match all or Match any, such as status is Open and (country is IN or US). In JS Query, use Filter.or and Filter.and to mix them.

Why does Firestore say my query needs an index?

Queries that filter on one field and sort on another, or combine several range filters, need a composite index. Firetool shows Firestore's message with a Create the index for this query… button that opens the index form filled in. Creating an index needs Pro; listing them is free.

Can I see why a Firestore query is slow or costly?

Yes. Explain this query shows the index Firestore uses without reading anything, or runs the query once and shows how many index entries and documents it scanned, the reads it made, the time it took and the estimated cost. When an index would help, it suggests one. It works in the Free edition.

Does counting documents with Σ Totals cost reads?

Far fewer than loading them. Firestore works the total out on its side and bills about one read per 1,000 documents matched, instead of one read for every document.

Is there a drag-and-drop query builder?

No. Simple mode is a query bar where you add filter and sort lines and pick operators from a list. For anything it can't express, JS Query takes Admin SDK-style code.

New in 3.0

Explain this query, and the indexes it needs

Actions ▾, Explain this query shows how Firestore runs the query of the last Run. Show the plan names the index it would use and reads nothing. Run and measure runs it once and shows the documents returned, the index entries and documents scanned, the reads, the time in Firestore and the estimated cost. When it looks at far more than it returns, Firetool says so and offers the composite index that would go straight to the matching documents. From 4.2 it says in plain words what would help, what the query costs at a number of runs a day, and what changed since you last measured it.

  • Index advice in Composite indexes: the indexes your recent and saved queries need and don't have
  • Duplicate indexes, and indexes whose fields start a longer one, which may not be needed
  • How many of Firestore's 200 composite indexes the database uses
  • No guessing at unused indexes: Firestore doesn't record which index a query used
Explain a query
Explain this query in Firetool: the index used, the documents returned, entries scanned, reads and time, what the query costs at 1,000 runs a day, and its advice

Side by side

Split view, map view and the data as it was

View, Split view opens a second view beside the first, with its own tabs, query and editor: staging next to production, or two collections at once. Map shows the documents that have a GeoPoint (or latitude and longitude) on a world map drawn by the app, so nothing goes to a map service. Show as of… runs the query on the data as it was, up to an hour ago, or 7 days with point-in-time recovery.

  • Both views follow the same rules and audit log
  • Hover a point for its ID; click to open the document
Firetool's split view: two collections side by side, each with its own query bar and table

New in 4.5.4

Pipeline queries, step by step

Actions ▾, Pipeline… opens the Pipeline tab for a collection or its collection group. Add steps without writing code, run it, and click a result to open the document. A pipeline without a Limit asks first, since every matching document is a read. Copy as code and Open in JS Query give the same pipeline as a script. Pipelines only read, and run on Firestore Enterprise edition databases; a Standard edition one says so in plain words.

Pipelines and vector search
  • Filter (all or any conditions, exists or missing, starts with, contains text), Sort, Limit and Skip
  • Keep or Remove fields, Distinct values and Random sample
  • Totals: count, sum, average, minimum, maximum and count different, grouped by fields
  • Find nearest: vector search by cosine, Euclidean or dot product, with the distance as a field
  • Make embeddings… fills a vector field from your documents' text with your AI service (Pro)
  • Steps kept for each collection on this computer

New in 2.26

Less retyping, more answers

Query history

⟲ lists the queries you ran with filters or sorts, here and in other collections. Choose one to run it again.

The query as code

</> turns the last query into code for Node.js (Admin SDK), the web (modular SDK), Python or Flutter, with typed values.

Suggestions in JS Query

Collection names, the fields of that collection and the Admin SDK's methods are suggested as you type a script.

Pipelines

On Firestore Enterprise edition databases, JS Query runs pipeline queries with db.pipeline(), in the SDK's own words. Only pipelines that read.

Dashboard

Add any chart to the Dashboard; each card keeps its query and is drawn again with fresh data.

Map view

Locations from GeoPoint fields or lat / lng numbers, with drag, zoom and Fit.

Try it on your own data

Free for Windows, macOS and Linux, with every Pro feature for the first 30 days.