The searchParams property of the URL interface returns a URLSearchParams object allowing access to the GET query arguments contained in the URL.

Syntax

var urlSearchParams = URL.searchParams;

Value

URLSearchParams object.

Example

If the URL of your page is https://example.com/?name=Jonathan&age=18 you could parse out the 'name' and 'age' parameters using:

let params = (new URL(document.location)).searchParams;
let name = params.get("name"); // is the string "Jonathan"
let age = parseInt(params.get("age")); // is the number 18

Specifications

Specification Status Comment
URL
The definition of 'searchParams' in that specification.
Living Standard Initial definition.

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung Internet
Basic supportChrome Full support 51Edge Full support 17Firefox Full support 52IE No support NoOpera Full support YesSafari Full support 10WebView Android Full support 51Chrome Android Full support 51Edge Mobile ? Firefox Android Full support 52Opera Android ? Safari iOS ? Samsung Internet Android ?

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown

Document Tags and Contributors

Last updated by: ExE-Boss,