Premium tools, free for everyone. Most run right in your browser.

OpenMultiURL

Links and URLs

How to Extract URLs From Text and Keep Links Intact

The title How to Extract URLs From Text and Keep Links Intact on a coloured card

A copied email can leave you with web addresses buried between greetings, notes, and repeated links. I want the addresses, not another editing job. When I extract URLs from text, I separate finding the links from cleaning them and opening them. That distinction matters: a missing query string can change the destination, while an extra closing bracket can spoil the result. I'll show you a quick workflow, a simple regex option, and the checks I make before using the list.

What does it mean to extract URLs from text?

When I extract links from text, I pull address-shaped strings out of surrounding words. The source might be an email, research notes, a log, or copied document text. My result is a list of addresses, ideally with each address on its own line. I'm not downloading the pages or checking their contents at this stage.

I separate discovery from validation

Finding a likely URL and parsing a URL are different jobs. The HTML Standard's explanation of URL parsing describes turning a string into a URL record. It doesn't promise to discover every address inside ordinary writing. And even a correctly parsed address doesn't prove that a page exists, that you can access it, or that it's safe.

I choose my method according to the source and the work I need to repeat.
MethodWhen I'd use itWhat I'd watch
Manual search and copyingA short block with obvious addressesMissed links and copied punctuation
URL-matching regexLong text or a repeated taskOver-captured punctuation and unsupported formats
Spreadsheet workflowText already arranged in cellsWhether a formula returns every match
HTML or document parsingDestinations hidden behind link labelsRelative paths and document-specific structure

For a short block, I start with the browser or editor's search rather than setting up code. On Android, the browser menu commonly calls this Find in page; on a laptop, I use Find. Searching for https:// and then http:// helps me locate explicit web addresses. It isn't automatic extraction, but it's a practical option when the list is short.

  1. I copy the source into a plain text editor and keep an untouched copy.
  2. I find each explicit web address and copy it onto a separate line in a working list.
    • I search separately for www. if the source uses addresses without a scheme.
    • I check the end of each match against the original sentence.
  3. I review repeated addresses and leave query strings intact unless I have a reason to change them.
  4. I open Open Multiple URLs and paste the reviewed addresses into its URL input.
  5. I use its opening control only after checking the destinations, starting with a small selection rather than the whole collection.

I build the tools on OpenMultiURL and test on a budget Android phone and a laptop. I've tried this prepared-list workflow with Open Multiple URLs. Its role here is opening the list after extraction. I wouldn't describe a bulk opener as a universal extractor for prose, HTML, and documents.

Tip from me: I keep the source text and extracted list separate. If cleanup damages an address, I can compare it with the original instead of guessing what disappeared.

What should a clean extracted URL list look like?

I aim for one complete address per line, without labels or surrounding sentences. I don't sort or deduplicate immediately because the original order can help me trace a link back to its source. These examples are sample text, not claims that the example pages exist.

I use the surrounding sentence to decide what belongs in each extracted result.
Sample source textWorking resultMy review
Read https://example.com/guide for details.https://example.com/guideThe following words clearly end the address.
See (https://example.com/help).https://example.com/helpThe brackets surround the address in this sentence.
Search https://example.com/search?q=notes&lang=enhttps://example.com/search?q=notes&lang=enI preserve both query parameters.
Again: https://example.com/guidehttps://example.com/guideI keep the repetition until I decide whether it matters.
Visit www.example.com/helpwww.example.com/helpI flag the missing scheme instead of silently assuming one.

My first output is a faithful working copy, not a polished report. If a repeated link tells me how often a source was mentioned, removing it would lose useful information. If I only need pages to visit, keeping repeated identical addresses would add clutter. I decide which task I'm doing before changing the list.

Which URL formats can a text extraction method find?

I define the input before trusting the result

There isn't a single promise behind the phrase URL extractor. A method built to find HTTP and HTTPS addresses may ignore www addresses, bare domains, email links, and relative paths. I want the supported inputs stated clearly. Otherwise, a tidy result can hide the fact that the method missed part of the source.

  • I treat https://example.com/page as an explicit web address with a scheme.
  • I treat www.example.com as a separate recognition case because it has no HTTP or HTTPS prefix.
  • I review bare example.com carefully because domain-shaped text can appear in ordinary prose.
  • I don't expect an HTTP-only pattern to return mailto addresses or other schemes.
  • I need a base address to resolve a relative path such as /help into an absolute URL.

For the last case, I follow the distinction in MDN's explanation of URLs. A relative path gets its meaning from context. I can't reliably turn /help into a complete address when the copied text doesn't tell me which website it belongs to.

How do I extract URLs from a string using regex?

For repeatable extraction, I use a regex to collect candidates, then review the boundaries. A regex is a text-matching pattern. It can save copying work, but I wouldn't sell a short pattern as a complete understanding of URL syntax. My example below is JavaScript and deliberately handles only explicit HTTP and HTTPS addresses.

I start with a limited JavaScript pattern

With the source string stored in a variable called text, this JavaScript expression returns an array of candidate matches: text.match(/https?:\/\/[^\s<>"']+/gi) || []

I read that as: find HTTP or HTTPS, then keep collecting characters until whitespace, an angle bracket, or a quote. The final flags search throughout the string without making letter case significant. This isn't a pattern for www links or relative paths, and it can still include a sentence-ending period or closing parenthesis.

After reviewing boundaries, I can pass a candidate to JavaScript's URL constructor. MDN documents that invalid input can throw a TypeError. I'd handle that error rather than letting one bad candidate stop the whole task. Parsing remains a separate check; it doesn't tell me whether a server will answer.

Which punctuation and cleanup mistakes should I avoid?

The awkward part is usually where the address ends. A pattern that reads until whitespace can swallow sentence punctuation. But cutting at every comma or parenthesis can remove valid URL content. I use the source sentence as evidence rather than applying a blanket rule to every match.

  • I don't strip all punctuation. Commas, semicolons, and parentheses may belong inside an address.
  • I compare closing brackets with the surrounding text. A bracket enclosing a link is different from one inside its path.
  • I inspect wrapped links before joining lines. Removing every line break can glue unrelated text onto an address.
  • I preserve query strings and fragments unless the task specifically calls for changing them.
  • I don't assume every missed link is an extractor fault. The copied source may contain only a label or an incomplete address.

The formal background is useful here: RFC 3986 describes URI components and discusses separating references from surrounding text. My practical lesson is simpler. I check uncertain endings against the original instead of deleting characters just because they look untidy.

Tip from me: When a long address breaks across lines, I compare the text on both sides of the break before joining it. I don't run a whole document through a line-joining operation just to repair one link.

I distinguish visible text from hidden destinations

If an email displays the words Read the report, the destination may be stored behind those words. Copying the visible sentence into a text extractor might not include it. I use the email or document application's link-copying option for individual destinations, or work with the underlying format when I need a repeatable extraction process.

For HTML, I want a parser that reads link destinations from href attributes rather than a search through visible prose. Relative destinations still need the page's base context. Markdown needs its own care because a destination can sit beside a descriptive label, and brackets or parentheses can complicate a simple whitespace-based match.

For a PDF, I first need usable text. PDF to Text is a starting point for a text-extraction workflow, not a promise to recover every hidden hyperlink destination. A scanned page is a different input problem because the address may exist only as an image. Pasting an image into a text workflow won't automatically make its printed addresses searchable.

In Excel or Google Sheets, I first ask whether each cell contains visible addresses, several addresses mixed with notes, or linked display text. Those are different tasks. I choose an extraction formula or script for the actual cell contents and check whether it returns every match rather than only the first one.

How do I remove duplicates and prepare the final list?

Once I've checked the candidates, I make a working copy for cleanup. My default is to preserve full addresses. Reducing everything to domains would merge different pages, while removing query strings could change a search or another destination. Clean doesn't mean short; it means suitable for what you need next.

  1. I put each complete address on its own line so I can compare and reuse the results.
  2. I use URL Deduplicator when I want to remove repeated URLs, reviewing how any equivalence options affect the result.
  3. I sort only after saving the original order, especially when source order carries meaning.
  4. I extract domains only if my task is about websites rather than individual pages.

I keep those jobs separate with URL Deduplicator, URL Sorter, and Domain Extractor. A domain-only list is useful for grouping websites, but I don't overwrite my full-address list with it. Otherwise, I lose the paths that tell me which pages I collected.

If tracking parameters need attention, I treat that as another deliberate operation. I don't delete everything after a question mark. I compare the cleaned version with the original and keep the original available, especially when a query includes a search term, item identifier, or another value needed by the destination.

Before I paste anything into an online service, I look at what the text contains. An otherwise ordinary link can carry an access token, and an email can contain personal or confidential information around it. I remove material I don't need and follow any rules that apply to the document before choosing a processing method.

I don't confuse local processing with a reassuring label

A claim that something runs locally needs support from its implementation and privacy information. If you're technical, inspecting the code and browser network activity can help you investigate what a page sends. I don't treat one quiet moment in the network panel as a complete privacy audit. For sensitive material, I prefer an approved offline workflow over an assumption.

I also review destinations before opening them. Extraction isn't malware screening, and a familiar-looking label isn't evidence about the actual domain. I can inspect an address's parts with URL Parser, but parsing doesn't certify trustworthiness. If I don't trust a destination, I leave it unopened rather than treating collection as permission to visit.

Questions people ask

How can I extract all links from a block of text at once?

I use a matching pattern or an extractor whose supported inputs fit the source, then review the complete result. For explicit HTTP and HTTPS addresses, a regex can collect candidates together. I still check punctuation and wrapped lines, and I don't assume that visible-text extraction includes hidden hyperlink destinations.

Can I extract URLs that start with www but have no http or https?

Yes, but I need a method that explicitly recognises www addresses. The JavaScript pattern in this post doesn't, because it deliberately starts with HTTP or HTTPS. I review those matches separately and keep a record of any scheme I add rather than pretending the original text supplied it.

How do I extract URLs from text in Excel or Google Sheets?

I first check what the cells actually contain. A cell with visible URL text needs a different approach from a cell showing a linked label. For mixed text, I choose a supported formula or script and check its matching behaviour. I wouldn't assume a formula that finds one address extracts every address.

How can I extract URLs without including commas, periods, or brackets after them?

I use surrounding text and delimiter balance to review the match ending. I don't remove every punctuation mark because some belong inside valid URLs. If the boundary is uncertain, I keep the original candidate alongside my edited version so I can check what I changed before using it.

How do I remove duplicate URLs from an extracted list?

I save an untouched list, put each address on its own line, and use URL Deduplicator on a working copy. Before merging near-matches, I decide whether differences in schemes, paths, queries, or fragments matter to my task. Exact repetition is a different question from whether different addresses represent equivalent content.

Does extracting a URL check whether the link works?

No. I treat extraction as finding a candidate address in text. Parsing can then check whether software accepts its structure, but that still doesn't establish availability or safety. A destination might require access you don't have, and I don't consider an extracted list a set of verified pages.

What to do next

I start by saving the source, choosing a method that fits its format, and collecting complete addresses without changing them. Then I check uncertain endings, repair only the breaks I understand, and decide whether duplicates should stay. You can follow that same order with your next copied email or document. Keep a full-address master list before sorting or reducing it to domains. When the destinations are reviewed and you're ready to visit them, paste a small selection into Open Multiple URLs. I'd rather open a short, checked list than rush through a longer one whose contents I haven't understood.

Sources I checked

Tools from this guide

Keep reading