JavaScript URLSearchParams

Beginner
6 min read
Updated: Nov 2026

Definition and Usage

URLSearchParams reads and writes query strings: get, set, append, delete, and iteration.

TopicSummary
basicsget, set, append, toString.

JavaScript Syntax

JavaScript
const q = new URLSearchParams("a=1&b=2");
q.set("a", "9");
console.log(q.get("a"));
console.log(q.toString());
Try it Editor

How It Works

  1. Parse. From a query string.
  2. set/get. Update values.
  3. toString. Serialize without leading ?.

Examples

Example 1 — Quick demo

Core usage.

JavaScript
const q = new URLSearchParams("a=1&b=2");
q.set("a", "9");
console.log(q.get("a"));
console.log(q.toString());
Try it Editor

How It Works

  1. Parse. From a query string.
  2. set/get. Update values.
  3. toString. Serialize without leading ?.

Frequently Asked Questions

URLSearchParams reads and writes query strings: get, set, append, delete, and iteration.
Together with the Fetch API for HTTP requests in the browser (and modern Node).

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

6 people found this page helpful