New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

firebase-tools-cli

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

firebase-tools-cli

CLI tool for Firebase to manage Firestore, Remote Config, and Realtime Database

latest
Source
npmnpm
Version
6.0.0
Version published
Weekly downloads
2
-50%
Maintainers
1
Weekly downloads
 
Created
Source

Firebase Tools CLI

NPM version License Node Version NPM version Bun compatible

The Firebase Tools CLI is a command-line interface for managing Firebase services including Firestore, Realtime Database, and Remote Config. It provides powerful tools to export, import, query, and manage your Firebase data from the command line.

  • Export/Import data from Firestore and Realtime Database
  • Query collections and documents with advanced filtering
  • Convert JSON files to Firebase Remote Config format
  • Manage authentication and project settings
  • Batch operations with customizable batch sizes

To get started with Firebase Tools CLI, read the full list of commands below or check out the documentation.

Installation

Node Package

You can install Firebase Tools CLI using npm (the Node Package Manager). Note that you will need to install Node.js and npm. Installing Node.js should install npm as well.

To download and install Firebase Tools CLI run the following command:

npm install -g firebase-tools-cli

This will provide you with the globally accessible firebase-tools-cli command.

Bun

Firebase Tools CLI also supports Bun (>=1.0.0) as a runtime. You can install it globally using Bun's package manager:

bun install -g firebase-tools-cli

Or run commands directly with Bun after a local install:

bun run firebase-tools-cli --help

Note: Core features are expected to be compatible with Bun. Some interactive prompts that rely on Node.js-specific stdin handling may behave slightly differently under Bun. If you encounter issues, please open an issue.

Commands

The command firebase-tools-cli --help lists the available commands and firebase-tools-cli <command> --help shows more details for an individual command.

If a command is project-specific, you must have either a valid Firebase service account key file

Below is a brief list of the available commands and their function:

Authentication Commands

CommandDescription
loginAuthenticate with service account key file.
projectsList available projects and manage default project settings.
resetReset all configuration and credentials. Options to reset config-only or credentials-only.

Firestore Commands

CommandDescription
firestore:exportExport all collections from Firestore to a single compact importable JSON file (firestore_export.json). Supports subcollection handling and collection exclusions.
firestore:importImport data to Firestore from JSON file. Supports batch operations and merge functionality.
firestore:listList all collections and their basic information from the current project's Firestore database.
firestore:queryQuery a collection or fetch a specific document. Supports subcollection paths (e.g., users user1 orders), collection group queries (--collection-group), advanced filtering, ordering, and field-specific queries.

Realtime Database Commands

CommandDescription
rtdb:exportExport all data from Realtime Database to a single compact importable JSON file (rtdb_export.json). Supports exclusion options and top-level-only export.
rtdb:importImport data to Realtime Database from JSON file. Supports batch operations and merge functionality.
rtdb:listList all top-level nodes and their basic information from the current project's Realtime Database.
rtdb:queryQuery a specific path in Realtime Database. Supports deep nested paths (e.g., /root/a/b/c), nested field filters (field/subfield,==,value), ordering, and JSON output with file saving.

Remote Config Commands

CommandDescription
remote-config:convertConvert JSON file to Firebase Remote Config format. Supports templates and condition generation.

Authentication

General

The Firebase Tools CLI currently only supports one authentication method:

  • Service Account - set the GOOGLE_APPLICATION_CREDENTIALS environment variable to point to the path of a JSON service account key file. For more details, see Google Cloud's Getting started with authentication guide.

Multiple Projects

By default the CLI can work with multiple Firebase projects. Use firebase-tools-cli projects to list available projects and set a default project for easier command execution.

To set the default project for a specific directory, run firebase-tools-cli projects --set-default <project-id> from within the directory.

To clear the default project setting, run firebase-tools-cli projects --clear-default.

Examples

Export and Import Workflow

# Export Firestore data
firebase-tools-cli firestore:export --output ./backup-$(date +%Y%m%d)/

# Import data to another project
firebase-tools-cli firestore:import ./backup-20231201/firestore_export.json

# Export Realtime Database
firebase-tools-cli rtdb:export --database-url https://source-project-rtdb.firebaseio.com/ --output ./rtdb-backup/

# Import to target database
firebase-tools-cli rtdb:import ./rtdb-backup/rtdb_export.json --database-url https://target-project-rtdb.firebaseio.com/

Advanced Querying

# Query Firestore collections with conditions
firebase-tools-cli firestore:query users --where "age,>=,18" --limit 10
firebase-tools-cli firestore:query users --order-by "name,asc"

# Query Firestore subcollections (nested paths)
firebase-tools-cli firestore:query users user1 orders
firebase-tools-cli firestore:query users user1 orders --where "status,==,shipped" --limit 5
firebase-tools-cli firestore:query users user1 orders order1

# Query Firestore collection groups (all subcollections with the same name)
firebase-tools-cli firestore:query orders --collection-group
firebase-tools-cli firestore:query orders --collection-group --where "status,==,shipped" --limit 20

# Query specific document fields
firebase-tools-cli firestore:query users user1 --field profile.settings

# Query Realtime Database with filtering
firebase-tools-cli rtdb:query users --where "age,>=,18" --limit 10 --database-url https://my-project-rtdb.firebaseio.com/
firebase-tools-cli rtdb:query posts --order-by "timestamp,desc" --json --output results.json

# Query Realtime Database at a nested path
firebase-tools-cli rtdb:query users/user4/active --database-url https://my-project-rtdb.firebaseio.com/
firebase-tools-cli rtdb:query users user4 active --database-url https://my-project-rtdb.firebaseio.com/

# Query Realtime Database with nested field filters
firebase-tools-cli rtdb:query users --where "workouts/appVersion,==,2.3.1" --database-url https://my-project-rtdb.firebaseio.com/
firebase-tools-cli rtdb:query workouts --where "settings/difficulty,>=,3" --order-by "settings/duration,desc" --database-url https://my-project-rtdb.firebaseio.com/

Remote Config Management

# Convert app config to Remote Config format
firebase-tools-cli remote-config:convert app-config.json --template mobile --add-conditions

# Convert with custom settings
firebase-tools-cli remote-config:convert config.json --version-number 2 --user-email admin@example.com --description "Production config"

Requirements

  • Node.js >= 18.0.0 or Bun >= 1.0.0
  • Valid Firebase project with appropriate permissions
  • Service account key

Contributing

We welcome contributions to Firebase Tools CLI! Please see CONTRIBUTING.md for guidelines on how to contribute.

License

Firebase Tools CLI is licensed under the MIT License.

Support

Contributors

Keywords

firestore

FAQs

Package last updated on 07 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts