0

This is my local storage, I want to somehow export it from this page and import it to another. How can this be done? I wish to export it for backup purpose too.

enter image description here

halfer
  • 19,824
  • 17
  • 99
  • 186
user2828442
  • 2,415
  • 7
  • 57
  • 105
  • Are both of the projects on the same domain? – BenM Sep 09 '17 at 08:30
  • yes same app, you can think of export and import option – user2828442 Sep 09 '17 at 08:40
  • https://stackoverflow.com/questions/4177803/can-html5-databases-and-localstorage-be-shared-across-subdomains – BenM Sep 09 '17 at 08:41
  • but how can i export it as some file and import it later...in 1 software i saw this option, they used to export it as filename.anyextensionname and later import it – user2828442 Sep 09 '17 at 08:41
  • Probably they just saved the localStorage data in a JSON format, and then wrote an exporter / importer. – BenM Sep 09 '17 at 08:42
  • Possible duplicate of [export Data in localStorage for later re-import](https://stackoverflow.com/questions/13335967/export-data-in-localstorage-for-later-re-import) – yuriy636 Sep 09 '17 at 08:43
  • Also [How to write localStorage data to a text file in Chrome](https://stackoverflow.com/questions/8693289/how-to-write-localstorage-data-to-a-text-file-in-chrome) – yuriy636 Sep 09 '17 at 08:48

2 Answers2

2

To export:

 const export = JSON.stringify(localStorage);

To import:

 Object.assign(localStorage,JSON.parse(import));

How to get the exported string from the one page to the other is another question...

Jonas Wilms
  • 132,000
  • 20
  • 149
  • 151
1

StorageAce chrome extension can easily help you with this. You can Export/Copy local storage items of one page and Import those in another page.

Along with Local Storage, it also easily manage Session Storage and Cookies.

enter image description here

CodeZila
  • 919
  • 2
  • 14
  • 31