Is there a limit to the key length for localStorage?

chris picture chris · Dec 1, 2011 · Viewed 15k times · Source

Is there any limit (up to the amount of local storage available) for the key when using localStorage?

i.e. can I do something like:

localStorage.setItem("pretend that this is a 1MB string", "whatever"); 

Answer

Aniket picture Aniket · Dec 1, 2011

Yes, the limit is 5MB per domain. Your string can be as long as you want. The total usage must, however, be under 5 MB.

http://dev.w3.org/html5/webstorage/

http://www.stackoverflow.com/questions/2747285/html5-localstorage-restrictions-and-limits