var currentUrl = 'http://www.example.com/hello.png?w=100&h=100&bg=white'; var url = new URL(currentUrl); url.searchParams.set("w", "200"); // setting your param var newUrl = url.href; console.log(newUrl);