const url = new URL('https://example.com/?a=hello&b=world'); const params = new URLSearchParams([ ...Array.from(url.searchParams.entries())]).toString(); console.log(params); /*a=hello&b=world*/