chrome.browsingData Stay organized with collections Save and categorize content based on your preferences.
Description
Use thechrome.browsingData API to remove browsing data from a user's local profile.
Permissions
browsingDataYou must declare the"browsingData" permission in theextension manifest to use this API.
{"name":"My extension",..."permissions":["browsingData",],...}Concepts and usage
The simplest use-case for this API is a a time-based mechanism for clearing a user's browsing data.Your code should provide a timestamp which indicates the historical date after which the user'sbrowsing data should be removed. This timestamp is formatted as the number of milliseconds since theUnix epoch (which can be retrieved from a JavaScriptDate object using thegetTime() method).
For example, to clear all of a user's browsing data from the last week, you might write code asfollows:
varcallback=function(){// Do something clever here once data has been removed.};varmillisecondsPerWeek=1000*60*60*24*7;varoneWeekAgo=(newDate()).getTime()-millisecondsPerWeek;chrome.browsingData.remove({"since":oneWeekAgo},{"appcache":true,"cache":true,"cacheStorage":true,"cookies":true,"downloads":true,"fileSystems":true,"formData":true,"history":true,"indexedDB":true,"localStorage":true,"passwords":true,"serviceWorkers":true,"webSQL":true},callback);Thechrome.browsingData.remove() method lets you remove various types of browsing data with asingle call, and will be much faster than calling multiple more specific methods. If, however, youonly want to clear one specific type of browsing data (cookies, for example), the more granularmethods offer a readable alternative to a call filled with JSON.
varcallback=function(){// Do something clever here once data has been removed.};varmillisecondsPerWeek=1000*60*60*24*7;varoneWeekAgo=(newDate()).getTime()-millisecondsPerWeek;chrome.browsingData.removeCookies({"since":oneWeekAgo},callback);If the user is syncing their data,chrome.browsingData.remove() may automatically rebuild the cookiefor the Sync account after clearing it. This is to ensure that Sync can continue working, so thatthe data can be eventually deleted on the server. However the more specificchrome.browsingData.removeCookies() can be used to clear the cookie for the Sync account, and Syncwill be paused in this case.
Specific origins
To remove data for a specific origin or to exclude a set of origins from deletion, you can use theRemovalOptions.origins andRemovalOptions.excludeOrigins parameters. They can only be applied tocookies, cache, and storage (CacheStorage, FileSystems, IndexedDB, LocalStorage, ServiceWorkers, andWebSQL).
chrome.browsingData.remove({"origins":["https://www.example.com"]},{"cacheStorage":true,"cookies":true,"fileSystems":true,"indexedDB":true,"localStorage":true,"serviceWorkers":true,"webSQL":true},callback);https://www.example.com will delete cookies with a domain of.example.com as well.Origin types
Adding anoriginTypes property to the APIs options object lets you specify which types oforigins ought to be effected. Origins are divided into three categories:
unprotectedWebcovers the general case of websites that users visit without taking any specialaction. If you don't specify anoriginTypes, the API defaults to removing data from unprotectedweb origins.protectedWebcovers those web origins that have been installed as hosted applications.InstallingAngry Birds, for example, protects the originhttps://chrome.angrybirds.com, andremoves it from theunprotectedWebcategory. Be careful when triggering deletion ofdata for these origins: make sure your users know what they're getting, as this will irrevocablyremove their game data. No one wants to knock tiny pig houses over more often than necessary.extensioncovers origins under thechrome-extensions:scheme. Removing extension data is,again, something you should be very careful about.
We could adjust the previous example to remove only data from protected websites as follows:
varcallback=function(){// Do something clever here once data has been removed.};varmillisecondsPerWeek=1000*60*60*24*7;varoneWeekAgo=(newDate()).getTime()-millisecondsPerWeek;chrome.browsingData.remove({"since":oneWeekAgo,"originTypes":{"protectedWeb":true}},{"appcache":true,"cache":true,"cacheStorage":true,"cookies":true,"downloads":true,"fileSystems":true,"formData":true,"history":true,"indexedDB":true,"localStorage":true,"passwords":true,"serviceWorkers":true,"webSQL":true},callback);protectedWeb andextension origin types. These are destructive operations thatmay surprise your users if they're not well-informed about what to expect when yourextension removes data on their behalf.Examples
To try this API, install thebrowsingData API example from thechrome-extension-samplesrepository.
Types
DataTypeSet
A set of data types. Missing data types are interpreted asfalse.
Properties
- appcache
boolean optional
Websites' appcaches.
- cache
boolean optional
The browser's cache.
- cacheStorage
boolean optional
Chrome 72+Cache storage
- cookies
boolean optional
The browser's cookies.
- downloads
boolean optional
The browser's download list.
- fileSystems
boolean optional
Websites' file systems.
- formData
boolean optional
The browser's stored form data.
- history
boolean optional
The browser's history.
- indexedDB
boolean optional
Websites' IndexedDB data.
- localStorage
boolean optional
Websites' local storage data.
- passwords
boolean optional
DeprecatedSupport for password deletion through extensions has been removed. This data type will be ignored.
Stored passwords.
- pluginData
boolean optional
Deprecated since Chrome 88Support for Flash has been removed. This data type will be ignored.
Plugins' data.
- serverBoundCertificates
boolean optional
Deprecated since Chrome 76Support for server-bound certificates has been removed. This data type will be ignored.
Server-bound certificates.
- serviceWorkers
boolean optional
Service Workers.
- webSQL
boolean optional
Websites' WebSQL data.
RemovalOptions
Options that determine exactly what data will be removed.
Properties
- excludeOrigins
string[] optional
Chrome 74+When present, data for origins in this list is excluded from deletion. Can't be used together with
origins. Only supported for cookies, storage and cache. Cookies are excluded for the whole registrable domain. - originTypes
object optional
An object whose properties specify which origin types ought to be cleared. If this object isn't specified, it defaults to clearing only "unprotected" origins. Please ensure that youreally want to remove application data before adding 'protectedWeb' or 'extensions'.
- extension
boolean optional
Extensions and packaged applications a user has installed (be _really_ careful!).
- protectedWeb
boolean optional
Websites that have been installed as hosted applications (be careful!).
- unprotectedWeb
boolean optional
Normal websites.
- origins
[string, ...string[]] optional
Chrome 74+When present, only data for origins in this list is deleted. Only supported for cookies, storage and cache. Cookies are cleared for the whole registrable domain.
- since
number optional
Remove data accumulated on or after this date, represented in milliseconds since the epoch (accessible via the
getTimemethod of the JavaScriptDateobject). If absent, defaults to 0 (which would remove all browsing data).
Methods
remove()
chrome.browsingData.remove(
options: RemovalOptions,
dataToRemove: DataTypeSet,
): Promise<void>
Clears various types of browsing data stored in a user's profile.
Parameters
- options
- dataToRemove
The set of data types to remove.
Returns
Promise<void>
Chrome 96+
removeAppcache()
chrome.browsingData.removeAppcache(
options: RemovalOptions,
): Promise<void>
Clears websites' appcache data.
Parameters
- options
Returns
Promise<void>
Chrome 96+
removeCache()
chrome.browsingData.removeCache(
options: RemovalOptions,
): Promise<void>
Clears the browser's cache.
Parameters
- options
Returns
Promise<void>
Chrome 96+
removeCacheStorage()
chrome.browsingData.removeCacheStorage(
options: RemovalOptions,
): Promise<void>
Clears websites' cache storage data.
Parameters
- options
Returns
Promise<void>
Chrome 96+
removeCookies()
chrome.browsingData.removeCookies(
options: RemovalOptions,
): Promise<void>
Clears the browser's cookies and server-bound certificates modified within a particular timeframe.
Parameters
- options
Returns
Promise<void>
Chrome 96+
removeDownloads()
chrome.browsingData.removeDownloads(
options: RemovalOptions,
): Promise<void>
Clears the browser's list of downloaded files (not the downloaded files themselves).
Parameters
- options
Returns
Promise<void>
Chrome 96+
removeFileSystems()
chrome.browsingData.removeFileSystems(
options: RemovalOptions,
): Promise<void>
Clears websites' file system data.
Parameters
- options
Returns
Promise<void>
Chrome 96+
removeFormData()
chrome.browsingData.removeFormData(
options: RemovalOptions,
): Promise<void>
Clears the browser's stored form data (autofill).
Parameters
- options
Returns
Promise<void>
Chrome 96+
removeHistory()
chrome.browsingData.removeHistory(
options: RemovalOptions,
): Promise<void>
Clears the browser's history.
Parameters
- options
Returns
Promise<void>
Chrome 96+
removeIndexedDB()
chrome.browsingData.removeIndexedDB(
options: RemovalOptions,
): Promise<void>
Clears websites' IndexedDB data.
Parameters
- options
Returns
Promise<void>
Chrome 96+
removeLocalStorage()
chrome.browsingData.removeLocalStorage(
options: RemovalOptions,
): Promise<void>
Clears websites' local storage data.
Parameters
- options
Returns
Promise<void>
Chrome 96+
removePasswords()
chrome.browsingData.removePasswords(
options: RemovalOptions,
): Promise<void>
Support for password deletion through extensions has been removed. This function has no effect.
Clears the browser's stored passwords.
Parameters
- options
Returns
Promise<void>
Chrome 96+
removePluginData()
chrome.browsingData.removePluginData(
options: RemovalOptions,
): Promise<void>
Support for Flash has been removed. This function has no effect.
Clears plugins' data.
Parameters
- options
Returns
Promise<void>
Chrome 96+
removeServiceWorkers()
chrome.browsingData.removeServiceWorkers(
options: RemovalOptions,
): Promise<void>
Clears websites' service workers.
Parameters
- options
Returns
Promise<void>
Chrome 96+
removeWebSQL()
chrome.browsingData.removeWebSQL(
options: RemovalOptions,
): Promise<void>
Clears websites' WebSQL data.
Parameters
- options
Returns
Promise<void>
Chrome 96+
settings()
chrome.browsingData.settings(): Promise<object>
Reports which types of data are currently selected in the 'Clear browsing data' settings UI. Note: some of the data types included in this API are not available in the settings UI, and some UI settings control more than one data type listed here.
Returns
Promise<object>
Chrome 96+
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-11-26 UTC.