Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / JavaScript

URL.searchParams — query parameters

URL.searchParams exposes query parameters as a URLSearchParams object linked to the URL.

Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support

Syntax

url.searchParams

URL.searchParams is a URL instance property, not a static method. It is read-only, but the returned URLSearchParams object is mutable. Changes update the URL; repeated reads return the same object.

get() returns the first value or null; getAll() handles repeated names. set() replaces a name’s values with one value.

Serialization uses application/x-www-form-urlencoded: a space becomes +. This is a WHATWG Web API, not an ECMAScript edition feature; browser compatibility requires a separate check.

Examples

const url = new URL('https://example.com/?tag=js&tag=web');
const params = url.searchParams;
console.log(params.getAll('tag').join(','));
params.set('tag', 'api');
params.set('q', 'hello world');
console.log(url.href);

Result

js,web
https://example.com/?tag=api&q=hello+world

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources