.*
VALIDADOR ESPECIALIZADO

Validador de Regex para URLs

Valide links da web, nomes de domínio, query strings e protocolos em tempo real. Perfeito para sanitização de rotas de API.

Interactive URL Validator
//i
Valid Web URL
Test CasesBatch evaluation

URL Regex Validation FAQ

What is the best regex pattern for validating URLs?

A standard, dependable URL regex for web applications is: /^(https?:\/\/)?((([a-z0-9]([a-z0-9-]*[a-z0-9])?\.)+[a-z]{2,})|localhost)(:\d+)?(\/[-a-z0-9%_.~+]*)*(\?[;&a-z0-9%_.~+=-]*)?(\#[-a-z0-9_]*)?$/i. It checks protocol, domain/subdomain, optional port, path, query parameters, and hash anchors.

Should a URL regex require http:// or https://?

It depends on user intent. In forms where users might type 'google.com' without the scheme, allow the protocol to be optional using (https?:\/\/)?. In security-sensitive redirects (OAuth callbacks), always strictly require https:\/\/.

How do I validate URLs in JavaScript without complex regex?

Modern browsers and Node.js support the new URL(string) constructor. However, combining a regex validator with the URL API is recommended because new URL('http://foo') parses successfully even for non-routable domains.