DEV Community

Will Ceolin
Will Ceolin

Posted on • Edited on

How to delete all users from Firebase

Sometimes we need to wipe out our entire Firestore database. When that happens, it might also be useful to delete all existing users from the Firebase console.

As far as I know, we can't do that using the CLI. However, we can create a Cloud Function with an HTTPS trigger to delete all users:

export const deleteUsers = functions.https.onRequest(
  async (req, res): Promise<any> => {
    const allUsers = await auth.listUsers();
    const allUsersUID = allUsers.users.map((user) => user.uid);
    return auth.deleteUsers(allUsersUID).then(() => res.send("deleted"));
  }
);
Enter fullscreen mode Exit fullscreen mode

Follow me on Twitter

Top comments (0)