URL Parser & Query String Builder
Parse URLs into structured components, inspect query parameters, and generate parsing code for Python, JavaScript, PHP, and Go.
URL Components Explained
Every URL is made up of several standardized parts. Our parser breaks them down instantly.
| Component | Example | Description |
|---|---|---|
| Protocol (Scheme) | https: | The communication protocol used (http, https, ftp, ws, etc.) |
| Host / Domain | www.example.com | The server address. Includes subdomain if present. |
| Port | :8080 | Optional network port. Default is 80 (http) or 443 (https). |
| Path | /api/v1/users | The resource location on the server. |
| Query String | ?page=1&limit=20 | Key-value pairs for parameters, separated by &. |
| Hash (Fragment) | #section-2 | An in-page anchor. Never sent to the server. |
URL Parsing Code Snippets
Quick reference for parsing URLs in popular programming languages.
Python (urllib.parse)
from urllib.parse import urlparse, parse_qs
parsed = urlparse("https://example.com/api?key=value")
print(parsed.netloc) # "example.com"
print(parsed.path) # "/api"
print(parse_qs(parsed.query)) # {"key": ["value"]}JavaScript (URL API)
const url = new URL("https://example.com/api?key=value");
console.log(url.hostname); // "example.com"
console.log(url.pathname); // "/api"
console.log(url.searchParams.get("key")); // "value"PHP (parse_url)
$parsed = parse_url("https://example.com/api?key=value");
echo $parsed['host']; // "example.com"
echo $parsed['path']; // "/api"
parse_str($parsed['query'], $params);
print_r($params); // ["key" => "value"]Go (net/url)
import "net/url"
u, _ := url.Parse("https://example.com/api?key=value")
fmt.Println(u.Host) // "example.com"
fmt.Println(u.Path) // "/api"
fmt.Println(u.Query()["key"]) // ["value"]Frequently Asked Questions
How to parse a URL to get the domain name?
Using our online URL parser, you can simply paste your full web address into the input box above, and we will instantly extract the Host / Domain Name for you. If you need to do this programmatically, most languages provide built-in URL modules that securely separate the protocol (e.g., https://) from the domain (e.g., example.com) without manual string splitting.
How to parse a URL in Python?
In Python, you should use the built-in urllib.parse module. It is the most robust way to handle URL parsing in Python. Use urlparse(url) to get a structured object, then access .netloc for the domain and parse_qs() for query parameters.
How to parse a URL using JavaScript?
Modern browsers and Node.js environment both support the global URL object. It makes JavaScript URL parsing incredibly straightforward: const myUrl = new URL(urlString). You can then access myUrl.hostname for the domain and myUrl.searchParams.get(key) for individual query parameters.
What is parse_url in PHP?
parse_url() is a native PHP function that parses a URL and returns an associative array containing its various components (like scheme, host, path, and query). If you are building backend logic, using parse_url in PHP is much safer than using regular expressions.
How to use the Go (Golang) URL Parser?
In Golang, you can use the net/url package to parse standard URLs. Simply pass your string to url.Parse() to get a structured URL object back, giving you direct access to the Host, Path, and RawQuery fields.