tabs.query()

Gets all tabs that have the specified properties, or all tabs if no properties are specified.

Syntax

js
let querying = browser.tabs.query(queryInfo)

Parameters

queryInfo

object. The query() function gets the tabs whose properties match the properties included here.

See the tabs.Tab documentation to learn more about these properties.

active Optional

boolean. Whether the tabs are active in their windows.

attention Optional

boolean. Indicates whether the tabs are drawing attention.

audible Optional

boolean. Whether the tabs are audible.

autoDiscardable Optional

boolean. Whether the tab can be discarded by the browser. The default value is true. When set to false, the browser cannot automatically discard the tab. However, the tab can be discarded by tabs.discard.

cookieStoreId Optional

string or array of string. Use this to return tabs whose tab.cookieStoreId matches any of the cookieStoreId strings. This option is only available if the add-on has the "cookies" permission. See Work with contextual identities for more information.

currentWindow Optional

boolean. Whether the tabs are in the current window.

discarded Optional

boolean. Whether the tabs are discarded. A discarded tab is one whose content has been unloaded from memory, but is still visible in the tab strip. Its content gets reloaded the next time it's activated.

groupId Optional

integer. The ID of the tab group the tabs are in or -1 (tabGroups.TAB_GROUP_ID_NONE) for ungrouped tabs. For more information on tab groups, see tabGroups.

hidden Optional

boolean. Whether the tabs are hidden.

highlighted Optional

boolean. Whether the tabs are highlighted.

index Optional

integer. The position of the tabs within their windows.

muted Optional

boolean. Whether the tabs are muted.

lastFocusedWindow Optional

boolean. Whether the tabs are in the last focused window.

pinned Optional

boolean. Whether the tabs are pinned.

splitViewId Optional

integer. The ID of the split view the tab belongs to. Set to tabs.SPLIT_VIEW_ID_NONE to query the tabs that don't belong to a split view.

status Optional

tabs.TabStatus. Whether the tabs have completed loading.

title Optional

string. Match page titles against a pattern. Requires the "tabs" permission or host permissions for the tab to match.

url Optional

string or array of string. Match tabs against one or more match patterns. Note that fragment identifiers are not matched. Requires the "tabs" permission or host permissions for the tab to match.

windowId Optional

integer. The id of the parent window, or windows.WINDOW_ID_CURRENT for the current window.

windowType Optional

tabs.WindowType. The type of window the tabs are in.

Return value

A Promise that will be fulfilled with an array of tabs.Tab objects, containing information about each matching tab.

If any error occurs, the promise will be rejected with an error message.

Examples

Get all tabs:

js
function logTabs(tabs) {
  for (const tab of tabs) {
    // tab.url requires the `tabs` permission or a matching host permission.
    console.log(tab.url);
  }
}

function onError(error) {
  console.error(`Error: ${error}`);
}

browser.tabs.query({}).then(logTabs, onError);

Get all tabs in the current window:

js
function logTabs(tabs) {
  for (const tab of tabs) {
    // tab.url requires the `tabs` permission or a matching host permission.
    console.log(tab.url);
  }
}

function onError(error) {
  console.error(`Error: ${error}`);
}

browser.tabs.query({ currentWindow: true }).then(logTabs, onError);

Get the active tab in the current window:

js
function logTabs(tabs) {
  // tabs[0].url requires the `tabs` permission or a matching host permission.
  console.log(tabs[0].url);
}

function onError(error) {
  console.error(`Error: ${error}`);
}

browser.tabs
  .query({ currentWindow: true, active: true })
  .then(logTabs, onError);

Get tabs for all HTTP and HTTPS URLs under "mozilla.org" or any of its subdomains:

js
function logTabs(tabs) {
  for (const tab of tabs) {
    // tab.url requires the `tabs` permission or a matching host permission.
    console.log(tab.url);
  }
}

function onError(error) {
  console.error(`Error: ${error}`);
}

browser.tabs.query({ url: "*://*.mozilla.org/*" }).then(logTabs, onError);

Example extensions

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Firefox for Android
Safari on iOS
query
Chrome – Full support
Chrome 16 (Release date: 2011-12-13)
footnote Full support
Edge – Full support
Edge 14 (Release date: 2016-08-02)
footnote
footnote The panel, app, devtools and popup values for WindowType are not supported.
Firefox – Full support
Firefox 45 (Release date: 2016-03-08)
footnote Full support
Opera – Full support
Opera 15 (Release date: 2013-07-02)
footnote Full support
Safari – Full support
Safari 14 (Release date: 2020-09-16)
footnote Full support
Firefox for Android – No support
Firefox for Android 54 – 68 (Release date: 2017-06-13)
footnote Removed in 79 and later
Firefox for Android – Partial support
Firefox for Android 85 (Release date: 2021-01-26)
footnote Partial support
footnote May only return a subset of the matching tabs open in the Firefox for Android.
footnote See bug 1583281
Safari on iOS – Full support
Safari on iOS 15 (Release date: 2021-09-20)
footnote Full support
queryInfo
Chrome – Full support
Chrome 16 (Release date: 2011-12-13)
footnote Full support
Edge – Full support
Edge 14 (Release date: 2016-08-02)
footnote Full support
Firefox – Full support
Firefox 45 (Release date: 2016-03-08)
footnote Full support
Opera – Full support
Opera 15 (Release date: 2013-07-02)
footnote Full support
Safari – Full support
Safari 14 (Release date: 2020-09-16)
footnote Full support
Firefox for Android – No support
Firefox for Android 54 – 68 (Release date: 2017-06-13)
footnote Removed in 79 and later
Firefox for Android – Full support
Firefox for Android 85 (Release date: 2021-01-26)
footnote Full support
Safari on iOS – Full support
Safari on iOS 15 (Release date: 2021-09-20)
footnote Full support
queryInfo.active
Chrome – Full support
Chrome 16 (Release date: 2011-12-13)
footnote Full support
Edge – Full support
Edge 14 (Release date: 2016-08-02)
footnote Full support
Firefox – Full support
Firefox 45 (Release date: 2016-03-08)
footnote Full support
Opera – Full support
Opera 15 (Release date: 2013-07-02)
footnote Full support
Safari – Full support
Safari 14 (Release date: 2020-09-16)
footnote Full support
Firefox for Android – No support
Firefox for Android 54 – 68 (Release date: 2017-06-13)
footnote Removed in 79 and later
Firefox for Android – Full support
Firefox for Android 85 (Release date: 2021-01-26)
footnote Full support
Safari on iOS – Full support
Safari on iOS 15 (Release date: 2021-09-20)
footnote Full support
queryInfo.attention
Chrome – No support
Chrome
footnote No support
Edge – No support
Edge
footnote No support
Firefox – Full support
Firefox 63 (Release date: 2018-10-23)
footnote Full support
Opera – No support
Opera
footnote No support
Safari – No support
Safari
footnote No support
Firefox for Android – No support
Firefox for Android
footnote No support
Safari on iOS – No support
Safari on iOS
footnote No support
queryInfo.audible
Chrome – Full support
Chrome 45 (Release date: 2015-09-01)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 45 (Release date: 2016-03-08)
footnote Full support
Opera – Full support
Opera 32 (Release date: 2015-09-15)
footnote Full support
Safari – Full support
Safari 14 (Release date: 2020-09-16)
footnote Full support
Firefox for Android – No support
Firefox for Android 54 – 68 (Release date: 2017-06-13)
footnote Removed in 79 and later
Firefox for Android – Full support
Firefox for Android 85 (Release date: 2021-01-26)
footnote Full support
Safari on iOS – Full support
Safari on iOS 15 (Release date: 2021-09-20)
footnote Full support
queryInfo.autoDiscardable
Chrome – Full support
Chrome 54 (Release date: 2016-10-12)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 116 (Release date: 2023-08-01)
footnote Full support
Opera – Full support
Opera 41 (Release date: 2016-10-25)
footnote Full support
Safari – No support
Safari
footnote
footnote See bug 265970
Firefox for Android – No support
Firefox for Android
footnote No support
Safari on iOS – No support
Safari on iOS
footnote
footnote See bug 265970
queryInfo.cookieStoreId
Chrome – No support
Chrome
footnote No support
Edge – No support
Edge
footnote No support
Firefox – Partial support
Firefox 52 – 78 (Release date: 2017-03-07)
footnote Removed in 79 and later
footnote Partial support
footnote Before Firefox 97, this property only supported one string, not an array of strings.
Firefox – Partial support
Firefox 85 – 96 (Release date: 2021-01-26)
footnote Partial support
footnote Before Firefox 97, this property only supported one string, not an array of strings.
Firefox – Full support
Firefox 97 (Release date: 2022-02-08)
footnote Full support
Opera – No support
Opera
footnote No support
Safari – No support
Safari
footnote No support
Firefox for Android – No support
Firefox for Android
footnote No support
Safari on iOS – No support
Safari on iOS
footnote No support
queryInfo.currentWindow
Chrome – Full support
Chrome 19 (Release date: 2012-05-15)
footnote Full support
Edge – Full support
Edge 14 (Release date: 2016-08-02)
footnote Full support
Firefox – Full support
Firefox 45 (Release date: 2016-03-08)
footnote Full support
Opera – Full support
Opera 15 (Release date: 2013-07-02)
footnote Full support
Safari – Full support
Safari 14 (Release date: 2020-09-16)
footnote Full support
Firefox for Android – No support
Firefox for Android 54 – 68 (Release date: 2017-06-13)
footnote Removed in 79 and later
Firefox for Android – Full support
Firefox for Android 85 (Release date: 2021-01-26)
footnote Full support
Safari on iOS – Full support
Safari on iOS 15 (Release date: 2021-09-20)
footnote Full support
queryInfo.discarded
Chrome – Full support
Chrome 54 (Release date: 2016-10-12)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 57 (Release date: 2017-11-14)
footnote Full support
Opera – Full support
Opera 41 (Release date: 2016-10-25)
footnote Full support
Safari – No support
Safari
footnote
footnote See bug 265970
Firefox for Android – No support
Firefox for Android 57 – 68 (Release date: 2017-11-28)
footnote Removed in 79 and later
Firefox for Android – Full support
Firefox for Android 85 (Release date: 2021-01-26)
footnote Full support
Safari on iOS – No support
Safari on iOS
footnote
footnote See bug 265970
queryInfo.groupId
Chrome – Full support
Chrome 88 (Release date: 2021-01-19)
footnote Full support
Edge – Full support
Edge 88 (Release date: 2021-01-21)
footnote Full support
Firefox – Full support
Firefox 138 (Release date: 2025-04-29)
footnote Full support
Opera – Full support
Opera 74 (Release date: 2021-02-02)
footnote Full support
Safari – No support
Safari
footnote No support
Firefox for Android – No support
Firefox for Android
footnote No support
Safari on iOS – No support
Safari on iOS
footnote No support
queryInfo.highlighted
Chrome – Full support
Chrome 16 (Release date: 2011-12-13)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 60 (Release date: 2018-05-09)
footnote
footnote Treated as an alias for queryInfo.active.
Opera – Full support
Opera 15 (Release date: 2013-07-02)
footnote Full support
Safari – Full support
Safari 14 (Release date: 2020-09-16)
footnote Full support
Firefox for Android – No support
Firefox for Android 60 – 60 (Release date: 2018-05-09)
footnote Treated as an alias for queryInfo.active except when an extension has a popup open. In this situation, queryInfo.highlighted will return the popup, while queryInfo.active will return the tab that was selected before the popup opened.
Firefox for Android – No support
Firefox for Android 61 – 68 (Release date: 2018-06-26)
footnote Removed in 79 and later
footnote Treated as an alias for queryInfo.active.
Safari on iOS – Full support
Safari on iOS 15 (Release date: 2021-09-20)
footnote Full support
queryInfo.index
Chrome – Full support
Chrome 18 (Release date: 2012-03-28)
footnote Full support
Edge – Full support
Edge 14 (Release date: 2016-08-02)
footnote Full support
Firefox – Full support
Firefox 45 (Release date: 2016-03-08)
footnote Full support
Opera – Full support
Opera 15 (Release date: 2013-07-02)
footnote Full support
Safari – Full support
Safari 14 (Release date: 2020-09-16)
footnote Full support
Firefox for Android – No support
Firefox for Android 54 – 68 (Release date: 2017-06-13)
footnote Removed in 79 and later
Firefox for Android – Full support
Firefox for Android 85 (Release date: 2021-01-26)
footnote Full support
Safari on iOS – Full support
Safari on iOS 15 (Release date: 2021-09-20)
footnote Full support
queryInfo.lastFocusedWindow
Chrome – Full support
Chrome 19 (Release date: 2012-05-15)
footnote Full support
Edge – Full support
Edge 14 (Release date: 2016-08-02)
footnote Full support
Firefox – Full support
Firefox 45 (Release date: 2016-03-08)
footnote Full support
Opera – Full support
Opera 15 (Release date: 2013-07-02)
footnote Full support
Safari – Full support
Safari 14 (Release date: 2020-09-16)
footnote Full support
Firefox for Android – No support
Firefox for Android 54 – 68 (Release date: 2017-06-13)
footnote Removed in 79 and later
Firefox for Android – Full support
Firefox for Android 85 (Release date: 2021-01-26)
footnote Full support
Safari on iOS – Full support
Safari on iOS 15 (Release date: 2021-09-20)
footnote Full support
queryInfo.muted
Chrome – Full support
Chrome 45 (Release date: 2015-09-01)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 45 (Release date: 2016-03-08)
footnote Full support
Opera – Full support
Opera 32 (Release date: 2015-09-15)
footnote Full support
Safari – Full support
Safari 14 (Release date: 2020-09-16)
footnote Full support
Firefox for Android – No support
Firefox for Android 54 – 68 (Release date: 2017-06-13)
footnote Removed in 79 and later
Firefox for Android – Full support
Firefox for Android 85 (Release date: 2021-01-26)
footnote Full support
Safari on iOS – No support
Safari on iOS
footnote No support
queryInfo.openerTabId
Chrome – Full support
Chrome 18 (Release date: 2012-03-28)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 57 (Release date: 2017-11-14)
footnote Full support
Opera – Full support
Opera 15 (Release date: 2013-07-02)
footnote Full support
Safari – Full support
Safari 14 (Release date: 2020-09-16)
footnote Full support
Firefox for Android – No support
Firefox for Android
footnote No support
Safari on iOS – Full support
Safari on iOS 15 (Release date: 2021-09-20)
footnote Full support
queryInfo.pinned
Chrome – Full support
Chrome 16 (Release date: 2011-12-13)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 45 (Release date: 2016-03-08)
footnote Full support
Opera – Full support
Opera 15 (Release date: 2013-07-02)
footnote Full support
Safari – Full support
Safari 14 (Release date: 2020-09-16)
footnote Full support
Firefox for Android – No support
Firefox for Android 54 – 68 (Release date: 2017-06-13)
footnote Removed in 79 and later
Firefox for Android – Full support
Firefox for Android 85 (Release date: 2021-01-26)
footnote Full support
Safari on iOS – No support
Safari on iOS
footnote No support
queryInfo.splitViewId
Chrome – Full support
Chrome 140 (Release date: 2025-09-02)
footnote Full support
Edge – Full support
Edge 140 (Release date: 2025-09-05)
footnote Full support
Firefox – Full support
Firefox 149 (Release date: 2026-03-24)
footnote Full support
Opera – Full support
Opera 124 (Release date: 2025-11-13)
footnote Full support
Safari – No support
Safari
footnote No support
Firefox for Android – Full support
Firefox for Android 149 (Release date: 2026-03-24)
footnote Full support
Safari on iOS – No support
Safari on iOS
footnote No support
queryInfo.status
Chrome – Full support
Chrome 16 (Release date: 2011-12-13)
footnote Full support
Edge – Full support
Edge 14 (Release date: 2016-08-02)
footnote Full support
Firefox – Full support
Firefox 45 (Release date: 2016-03-08)
footnote Full support
Opera – Full support
Opera 15 (Release date: 2013-07-02)
footnote Full support
Safari – Full support
Safari 14 (Release date: 2020-09-16)
footnote Full support
Firefox for Android – No support
Firefox for Android 54 – 68 (Release date: 2017-06-13)
footnote Removed in 79 and later
Firefox for Android – Full support
Firefox for Android 85 (Release date: 2021-01-26)
footnote Full support
Safari on iOS – Full support
Safari on iOS 15 (Release date: 2021-09-20)
footnote Full support
queryInfo.title
Chrome – Full support
Chrome 16 (Release date: 2011-12-13)
footnote Full support
Edge – Full support
Edge 14 (Release date: 2016-08-02)
footnote Full support
Firefox – Full support
Firefox 45 (Release date: 2016-03-08)
footnote Full support
Opera – Full support
Opera 15 (Release date: 2013-07-02)
footnote Full support
Safari – Full support
Safari 14 (Release date: 2020-09-16)
footnote Full support
Firefox for Android – No support
Firefox for Android 54 – 68 (Release date: 2017-06-13)
footnote Removed in 79 and later
Firefox for Android – Full support
Firefox for Android 85 (Release date: 2021-01-26)
footnote Full support
Safari on iOS – Full support
Safari on iOS 15 (Release date: 2021-09-20)
footnote Full support
queryInfo.url
Chrome – Full support
Chrome 16 (Release date: 2011-12-13)
footnote Full support
Edge – Full support
Edge 14 (Release date: 2016-08-02)
footnote Full support
Firefox – Full support
Firefox 45 (Release date: 2016-03-08)
footnote
footnote Fails if the extension doesn't have the tabs permission.
footnote Before Firefox 56, moz-extension:// URLs were not allowed.
Opera – Full support
Opera 15 (Release date: 2013-07-02)
footnote Full support
Safari – Full support
Safari 14 (Release date: 2020-09-16)
footnote Full support
Firefox for Android – No support
Firefox for Android 54 – 68 (Release date: 2017-06-13)
footnote Removed in 79 and later
footnote Fails if the extension doesn't have the tabs permission.
footnote Before Firefox 56, moz-extension:// URLs were not allowed.
Firefox for Android – Full support
Firefox for Android 85 (Release date: 2021-01-26)
footnote
footnote Fails if the extension doesn't have the tabs permission.
Safari on iOS – Full support
Safari on iOS 15 (Release date: 2021-09-20)
footnote Full support
queryInfo.windowId
Chrome – Full support
Chrome 16 (Release date: 2011-12-13)
footnote Full support
Edge – Full support
Edge 14 (Release date: 2016-08-02)
footnote Full support
Firefox – Full support
Firefox 45 (Release date: 2016-03-08)
footnote Full support
Opera – Full support
Opera 15 (Release date: 2013-07-02)
footnote Full support
Safari – Full support
Safari 14 (Release date: 2020-09-16)
footnote Full support
Firefox for Android – No support
Firefox for Android 54 – 68 (Release date: 2017-06-13)
footnote Removed in 79 and later
Firefox for Android – Full support
Firefox for Android 85 (Release date: 2021-01-26)
footnote Full support
Safari on iOS – Full support
Safari on iOS 15 (Release date: 2021-09-20)
footnote Full support
queryInfo.windowType
Chrome – Full support
Chrome 16 (Release date: 2011-12-13)
footnote Full support
Edge – Full support
Edge 14 (Release date: 2016-08-02)
footnote Full support
Firefox – Full support
Firefox 45 (Release date: 2016-03-08)
footnote Full support
Opera – Full support
Opera 15 (Release date: 2013-07-02)
footnote Full support
Safari – Full support
Safari 14 (Release date: 2020-09-16)
footnote Full support
Firefox for Android – No support
Firefox for Android 54 – 68 (Release date: 2017-06-13)
footnote Removed in 79 and later
Firefox for Android – Full support
Firefox for Android 85 (Release date: 2021-01-26)
footnote Full support
Safari on iOS – Full support
Safari on iOS 15 (Release date: 2021-09-20)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
No support
No support
See implementation notes.
Has more compatibility info.

Note: This API is based on Chromium's chrome.tabs API. This documentation is derived from tabs.json in the Chromium code.