var u = new URL('https://server.de/test?q#h') u.hash = '' u.search = '' console.log(u.toString()) Run code snippetHide results