How to remove and clear all localStorage data [duplicate]

localStorage.clear();

should work.


If you want to remove/clean all the values from local storage than use

localStorage.clear();

And if you want to remove the specific item from local storage than use the following code

localStorage.removeItem(key);