Get all query string values using JavaScript

In this article, we’ll show you how to get all parameters of the query string from the URL using JavaScript.

Here, we will use the URLSearchParams to get a list of all query params.

Let’s consider the following URL for example to get a query string parameter values.

Instead of the URL you can also use the current page URL using the window.location.href.

Now simply run the following code to get the list of the query parameters in the object.

You can also get the value of the individual parameters. Use the code below.

You can combine all the above code and check the output in the console.

That’s it for today.
Thank you for reading. Happy Coding..!! 🙂

If you found value in this article,
you can support us by buying me a coffee! ☕

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *