Skip to Content
Platform.Ontology

localStorage

A browser store of up to about 5 MB per site that scripts read at any time and that survives restarts.

Works without askingFiles and storageIn sessionWeb browsersWhile you use itAfter you leave the site

In one line

Can keep up to about 5 MB of text notes per site, until cleared

A browser store of up to about 5 MB per site that scripts read at any time and that survives restarts.

Holds settings, drafts, and very often a tracker's visitor ID that is re-created if the cookie is deleted. It is not sent to servers on its own, but every script on the page can read it. A common 'respawn' source for IDs.

What it can and can't do

What the user does: Nothing. It happens as you use the site or change settings.

It can

  • Remember settings, drafts and sign in tokens
  • Keep them after you restart the browser
  • Use them again on every visit

It cannot

  • Let other sites see them
  • Hold large files
  • Keep them after you clear site data or close a private window
  • Keep them in Safari after 7 days of use without a visit

How it differs between platforms: Safari may delete it after 7 days of use without a visit. Chrome and Firefox do not.

Browser support

BrowserStatusFirst versionReleasedNote
ChromeSupported42010-01-25None
EdgeSupported122015-07-29None
FirefoxSupported3.52009-06-30None
SafariSupported42009-06-08None
Safari on iPhoneSupported3.22010-04-03None
Chrome on AndroidSupported182012-06-27None
Samsung InternetSupported1.02013-04-27None

How a site asks for it

APIwindow.localStorage.setItem(k, v)
Browser compat keysapi.Window.localStorage
How access is grantednone
What the user seesNone
Needs a secure context (HTTPS)No
Needs a user gestureNo
How long it lastsUntil cleared by user or evicted. Safari deletes script written storage after 7 days of Safari use without a user visit
How to take it backClear site data, browser privacy settings
Inside an iframeNot listed

Data you get

What comes back: Key value strings
Shape: string
How often: any time

FieldTypeUnitRangePrecision
quotaintegerMiBabout 5 per originapproximate

Technical limits

  • About 5 MiB per origin in Chrome, Firefox and Safari
  • Synchronous API blocks the main thread
  • Not shared across origins or (3P) partitions
  • No expiry set by the API
  • Not available in workers

The story

What it is

A store of up to about 5 MB per site that scripts can read any time and that survives restarts.

For you

You never see it. It is why a site remembers your dark mode, your last search or your game score the next time you come back.

For makers

It is the easiest way to keep small settings, so it is everywhere. It is also a place where trackers store IDs, because it survives restarts and any script on the page can read it.

Where you see it

TypeExampleApps
gamesA word game or puzzle keeps your streak and best score here.Wordle, 2048
productivityA to do list app remembers your tasks without needing an account.None named
shoppingA store remembers the items you recently viewed.None named
socialA social site remembers a draft post that you did not send.None named
adsA tracking script stores a visitor ID and your last ad click here.None named
analyticsA site analytics script keeps a session ID here to link visits together.Google Analytics
educationA learning site remembers where you stopped in a lesson.None named

Risks

  • Hidden trackers
  • Readable by any script

What the platform says

  • MDN: Web Storage API. Documents how sites save small amounts of data in the browser for later visits.

Good uses and abuse

Legitimate uses

  • User settings, offline drafts, feature flags

Known abuse

  • Respawning tracking IDs after cookie deletion

Scores

ScoreValueMeaning
Sensitivity3 of 5How revealing the data is
Utility5 of 5How useful it is to honest apps
Friction0 of 5How much the user has to do
Fingerprint bits0Rough identifying entropy, when known

History

  • 2020-03, Safari 13.1: ITP 7 day cap on script writable storage applied to localStorage
  • 2022-07, Firefox 103: Total Cookie Protection partitions it for all users
  • 2023-07, Chrome 115: Third party localStorage partitioned by top level site

Sources

How well checked: Checked against real behavior.

On this page