How to find the size of localStorage with JavaScript?

Sometimes, we want to find the size of localStorage with JavaScript.

In this article, we’ll look at how to find the size of localStorage with JavaScript.

How to find the size of localStorage with JavaScript?

To find the size of localStorage with JavaScript, we can convert it to a blob and get its size.

For instance, we write

const size = new Blob(Object.values(localStorage)).size;

to convert the localStorage object to a blob with

Blob(Object.values(localStorage))

Then we get the size of the blob with the size property.

Conclusion

To find the size of localStorage with JavaScript, we can convert it to a blob and get its size.