18

I am developing with Firebase and have data stored in the Realtime Database. I need to share my database structure for a question here on Stack Overflow, or just take a backup before making breaking changes. How can I do this using the Firebase Console?

Grimthorr
  • 6,856
  • 5
  • 41
  • 53
  • 1
    This isn't covered in the documentation, so I've added this Q&A-style so it can be linked to in comments. – Grimthorr Nov 08 '17 at 14:30

3 Answers3

19

Data can be exported from the Firebase Realtime Database as JSON:

  1. Login to the Database section of the Firebase Console.
  2. Navigate to the node you wish to export by clicking on it in the list (skip this to export all data).
  3. Click the 3-dot overflow menu icon, at the top-right of the data panel.
  4. Click Export JSON from the menu.

    console menu screenshot

Likewise, you can import a structure in the same fashion, using Import JSON.

Grimthorr
  • 6,856
  • 5
  • 41
  • 53
  • 5
    I have a 600MB database that I wanted to export but it doesn't lets me export that database and gives a Payload too large error – Ishan Jain Mar 18 '18 at 01:24
  • 2
    @IshanJain see my answer for jsons too big for the console https://stackoverflow.com/a/49529584/2327328 – philshem Mar 28 '18 at 11:18
  • I found a solution to my problem the day after I put my comment here. But Thanks for your suggestion, I'll try this tool if I am in a similar situation. @philshem – Ishan Jain Mar 28 '18 at 12:10
  • 1
    if it's not covered in this page, post your answer for the next curious person – philshem Mar 28 '18 at 16:45
  • Can you tell me what is the use of exporting database as JSON? – Rohit Singh Jan 21 '19 at 18:03
  • 1
    @RohitSingh - running *ad hoc* analytics, moving DB to another project (test/dev/live), etc – philshem Feb 07 '19 at 12:48
12

There is an Node.js tool called firebase-export, similar to firebase-import but not from Firebase itself, that will export JSON from the command line.

Firebase export helper utility for exporting excluded JSON from Firebase.

To install

npm install -g firebase-export

Usage example

$ firebase-export --database_url https://test.firebaseio-demo.com --firebase_secret '1234' --exclude 'settings/*, users/*/settings'

Github Repo


Note: Firebase has a REST API, so you can use any language to retrieve (export) data:

curl 'https://[PROJECT_ID].firebaseio.com/users/jack/name.json'

Here's an example curl request with filters

curl 'https://dinosaur-facts.firebaseio.com/dinosaurs.json?orderBy="height"&startAt=3&print=pretty'
philshem
  • 24,761
  • 8
  • 61
  • 127
  • 1
    I'm getting `TypeError: Cannot read property 'split' of undefined at list (/home/jlam/.nvm/versions/node/v12.11.1/lib/node_modules/firebase-export/bin/firebase-export.js:29:14)` with firebase-export – Julien Lamarche Oct 29 '19 at 20:01
  • @JulienLamarche I don't see that error, but I think it's this issue: https://github.com/sinisavukovic/firebase-export/issues/2#issuecomment-466890517 – philshem Oct 30 '19 at 15:30
1

If you have a large JSON file then it is safe to download it using Postman's Import feature because downloading a large JSON file sometimes faces failure in the middle of the way. You just need to click save the response after the response is reached. enter image description here

Gk Mohammad Emon
  • 6,084
  • 3
  • 42
  • 42