Skip to content
</>Inblix Dev ToolsAll tools

URL Regex Generator Online

Find every link in a block of text. The pattern captures the scheme, host, optional port, path, and query string, and stops at whitespace and angle brackets.

How it works

URLs are easier to match than emails because the character set that can appear in one is more constrained — there are no local parts with arbitrary characters — but "URL" still means different things to different people. This pattern matches anything with an explicit http or https scheme.

The character class stops at whitespace, angle brackets, and double quotes, which is what stops a match running past the end of a URL when the URL sits inside HTML or a quoted string. That also means a URL followed immediately by a full stop in a sentence will include the full stop, so check the last character of any match that comes from prose.

Bare domains without a scheme, such as example.com, are not matched. Adding the scheme-optional variant `(?:https?:\/\/)?` will match them, at the cost of false positives on version numbers and file names like "config.json". Decide based on whether your input is a list of domains or free text.

Ports, query strings, and fragments are all captured, because the character class permits colons, slashes, question marks, ampersands, and hashes. If you need only the host portion, capture group 1 in a pattern such as `https?:\/\/([^\s\/?#]+)`.

Trailing punctuation is the most common source of surprise with this pattern. A URL at the end of a sentence picks up the full stop, and one wrapped in parentheses picks up the closing bracket. Stripping them in code usually means a small additional replace rather than a more complicated pattern.

Use the URL Regex Generator

URLs
Paste text on the left to see the result.

Try an example:

Runs entirely in your browser — nothing you paste is uploaded or logged.

Worked examples

Real input and the exact output this page produces.

Example 1

Text

                      Docs at https://example.com/docs?page=2 and http://localhost:3000
                    

URLs

                      https://example.com/docs?page=2
http://localhost:3000
                    

Frequently asked questions

Why does my match include a trailing full stop?

The pattern stops at whitespace, angle brackets, and quotes — a full stop is a legal URL character, so it is included. Trim trailing punctuation from the results in code.

Can it match domains without a scheme?

Yes. Change the pattern to (?:https?:\/\/)?[^\s<>"]+ but expect false positives on file names and version strings in mixed content.

Does it match query strings and fragments?

Yes. Colons, slashes, question marks, ampersands, and hashes are all permitted inside the character class.

Others doing similar work.