URL: searchParams property

Note: This feature is available in Web Workers.

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

Value

A URLSearchParams object.

Examples

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

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

Specifications

Specification
URL Standard
# dom-url-searchparams

Browser compatibility

BCD tables only load in the browser