'How to get Firebase RealTime Database size breakdown

I have been using Firebase RealTime Database for a while. As I have a lot of information stored in Firebase RealTime Database, I wanted to know which paths (folder) are taking up a lot of space so I can optimize the usage. The detail storage only provide the total size used in the database. Is there any method I can use to know the size breakdown of each path (folder)?



Solution 1:[1]

There is nothing built into the Firebase Realtime Database API or console that does this automatically (that I know of at least).

The easiest way I can think of is to enable automatic backups, take one of those, and then traverse each branch of the tree. To determine the size of a branch, you can pass it to JSON.stringify() and log the length of string you get back, which will give you a decent approximation of its size.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Frank van Puffelen