Test and validate URL patterns with regex — match HTTP, HTTPS, and custom URL schemes
URL regex validation uses regular expressions to check whether a string conforms to valid URL syntax. A URL consists of a scheme (http, https, ftp), optional authority (user:pass@host:port), hostname or IP address, optional path, optional query string (key-value parameters after ?), and optional fragment (section after #). Regex patterns can validate any or all of these components.
URL validation is needed in form inputs that accept website addresses, link validation tools that check for broken URLs, web scrapers that extract URLs from text, content management systems that validate user-submitted links, and security tools that inspect URLs for malicious patterns. The challenge is that valid URLs can be surprisingly complex — including IPv6 addresses in brackets, internationalized domain names, percent-encoded characters, and unusual but valid schemes beyond http and https.
PinusX executes all regex matching with 100% client-side processing. Your test URLs — which may include internal API endpoints, staging server addresses, private network URLs, or URLs with authentication tokens — never leave your browser. This protects sensitive infrastructure details from exposure. In November 2025, jsonformatter.org leaked over 80,000 user credentials processed on their servers. PinusX eliminates this risk by running regex computation entirely in your browser tab using JavaScript, with no data transmitted to any external server.
A practical pattern is: ^https?://[\w.-]+(:\d+)?(/[\w./-]*)?(\?[\w.&=%-]*)?(#[\w-]*)?$ — this validates the scheme (http or https), hostname with optional port, optional path, optional query string, and optional fragment. It covers the vast majority of web URLs you will encounter.
A complete RFC 3986 compliant URL regex is extremely complex. Simple patterns cover 99% of real-world URLs. For complete validation, consider using the URL constructor in JavaScript (new URL(string)) which performs full parsing, then use regex only for additional pattern requirements specific to your use case.
Add (\?[^\s#]*)? to your URL regex to optionally match a query string. The query string starts with ? and contains key=value pairs separated by &. Example match: https://api.example.com/search?q=test&page=1. The \?[^\s#]* pattern matches the ? followed by any non-whitespace, non-fragment characters.
For format validation, the JavaScript URL API (new URL()) is more reliable and handles edge cases that regex misses. Use regex when you need pattern matching beyond format validity — for example, requiring specific domains, path patterns, or blocking certain URL schemes. Combining both approaches gives the most robust validation.
Your data never leaves your browser. 100% client-side processing.
Get instant alerts when your endpoints go down. 60-second checks, free forever.
Start Monitoring Free →