Remove Query String from URL Using jQuery / Javascript

Reading Time: 3 minutes

Inside this article we will see how to remove query string from url using jquery / javascript. If you are creating an application where you need to remove query string from url using jquery / javascript every time then this tutorial may help you.

Article is super easy to understand and also easy steps for implementation. There are several options and the way to remove query string from url for every developer may be different but using javascript functions may be same.


Original URL


Converted URL will have no query string parameters.


Learn More –

Let’s get started.

Create an Application

Create a folder with name query-string. Create a file index.html into it.

Open index.html and write this complete code into it.

<!DOCTYPE html>
<html lang="en">

    <title>How to Remove Query String from URL Using jQuery / Javascript</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">


    <script src=""></script>

    <script type="text/javascript">
        $(document).ready(function() {

            var uri = window.location.toString();
            if (uri.indexOf("?") > 0) {
                var clean_uri = uri.substring(0, uri.indexOf("?"));
                window.history.replaceState({}, document.title, clean_uri);



Application Testing

Open browser and type this –

URL – http://localhost/query-string/index.html?blog=onlinewebtutor&name=sanjay

Redirected URL


We hope this article helped you to learn how to remove query string from url using jquery / javascript Tutorial in a very detailed way.

If you liked this article, then please subscribe to our YouTube Channel for PHP & it’s framework, WordPress, Node Js video tutorials. You can also find us on Twitter and Facebook.

Sanjay KumarHello friends, I am Sanjay Kumar a Web Developer by profession. Additionally I'm also a Blogger, Youtuber by Passion. I founded Online Web Tutor and Skillshike platforms. By using these platforms I am sharing the valuable knowledge of Programming, Tips and Tricks, Programming Standards and more what I have with you all. Read more