Error Codes Wiki

Browser localStorage Quota Exceeded — Storage Limit & Alternatives

Warningweb development

About Browser localStorage Quota Exceeded

Fix 'QuotaExceededError: Failed to execute setItem on Storage' when localStorage exceeds its 5-10MB limit, with strategies for larger client-side storage. This guide covers everything you need to know about this topic, including common causes, step-by-step solutions, and answers to frequently asked questions.

Here are the key things to understand: localStorage has a fixed limit of approximately 5MB per origin (varies by browser). The limit is per origin (protocol + domain + port), shared across all tabs. localStorage stores strings only — objects must be JSON.stringify'd, increasing size. The 5MB limit counts characters, but multi-byte characters (Unicode) can reduce effective capacity. sessionStorage has the same limit but is per-tab and cleared when the tab closes. Understanding these fundamentals will help you diagnose and resolve this issue more effectively.

The most common reasons this occurs include: Storing too much data: accumulated cache, logs, or application state exceeding 5MB. Repeatedly writing without cleaning up old entries. Base64-encoded files (images, documents) consuming large amounts of space. Multiple features in the same app competing for the shared storage space. JSON serialization overhead increasing data size beyond original. Identifying the root cause is the first step toward finding the right solution.

To resolve this, follow these recommended steps: Check current usage: calculate total size of all localStorage items in DevTools Console. Clean up old data: implement TTL (time-to-live) for cached items. Switch to IndexedDB for larger storage needs (hundreds of MB available). Compress data before storing: use LZ-string or similar compression library. Use Cache API for storing network responses and static assets. If these steps do not resolve the issue, consider consulting additional resources or a qualified professional.

This article is part of our Browser Errors collection on Error Codes Wiki. We provide comprehensive, up-to-date information to help you find solutions quickly.

Quick Answer

What is the exact localStorage limit?

Approximately 5MB in most browsers, but it varies: Chrome/Firefox ~5MB, Safari ~5MB, IE ~10MB. The limit is per origin.

Overview

Fix 'QuotaExceededError: Failed to execute setItem on Storage' when localStorage exceeds its 5-10MB limit, with strategies for larger client-side storage.

Key Details

  • localStorage has a fixed limit of approximately 5MB per origin (varies by browser)
  • The limit is per origin (protocol + domain + port), shared across all tabs
  • localStorage stores strings only — objects must be JSON.stringify'd, increasing size
  • The 5MB limit counts characters, but multi-byte characters (Unicode) can reduce effective capacity
  • sessionStorage has the same limit but is per-tab and cleared when the tab closes

Common Causes

  • Storing too much data: accumulated cache, logs, or application state exceeding 5MB
  • Repeatedly writing without cleaning up old entries
  • Base64-encoded files (images, documents) consuming large amounts of space
  • Multiple features in the same app competing for the shared storage space
  • JSON serialization overhead increasing data size beyond original

Steps

  1. 1Check current usage: calculate total size of all localStorage items in DevTools Console
  2. 2Clean up old data: implement TTL (time-to-live) for cached items
  3. 3Switch to IndexedDB for larger storage needs (hundreds of MB available)
  4. 4Compress data before storing: use LZ-string or similar compression library
  5. 5Use Cache API for storing network responses and static assets

Tags

browserlocalstoragequotastorageweb-development

More in Web Development

Frequently Asked Questions

Approximately 5MB in most browsers, but it varies: Chrome/Firefox ~5MB, Safari ~5MB, IE ~10MB. The limit is per origin.