How to Extract All Links From Text, HTML Source or a Document

Find every URL in text or page source, handle brackets and trailing punctuation correctly, strip tracking parameters, group links by domain and export the list.

Updated September 29, 2026 5 min read

Use the free URL ExtractorPull every link out of text or HTML, group by domain and export

Links pile up in places that were never meant to be link lists: meeting notes, a long email thread with resources scattered through it, a document of research sources, a chat export, or the HTML source of a web page you are auditing. When you need them as a clean list, to check them, share them, import them into a spreadsheet or review which sites you link to, copying each one by hand is slow and easy to get wrong.

This guide explains how URLs are recognised in free text, the edge cases that trip up simple approaches, how to clean and group the results, and how to extract links in a browser, from a page's developer tools or on the command line.

What counts as a URL in text

A URL (web address) has a scheme, a host and usually a path:

https://example.com/docs/start?lang=en#install
scheme  host        path       query    fragment

In running text, links appear in a few forms:

  • Full URLs with https://, http:// or ftp://.
  • Bare www addresses, such as www.example.net/blog, where the writer left out the scheme.
  • Links inside HTML, in href and src attributes.
  • Links inside Markdown, like [guide](https://example.com).

An extractor looks for text that starts with a scheme or www. and continues until a character that cannot appear in a URL, such as a space, a quote or an angle bracket. To break a URL into its components once you have it, the URL Parser shows each part.

The tricky part: where does a URL end?

Punctuation is the classic problem. In "see https://example.com/page.", the full stop belongs to the sentence, not the address. The same goes for commas, colons, question marks and closing quotes at the end of a link.

Brackets are harder still. Some URLs legitimately contain parentheses, such as Wikipedia disambiguation pages ending in _(disambiguation). But a URL written inside brackets in a sentence, "(see https://example.com)", should not include the closing bracket. A good extractor trims a trailing bracket only when the URL has more closing than opening brackets, which handles both cases.

Our URL Extractor handles these edge cases and adds options for cleaning and organising the list.

  1. Open URL Extractor and paste into Text, HTML or Markdown with links. The Sample includes a link in brackets, a Wikipedia URL with parentheses, a www. address, an FTP link and a duplicate inside HTML.
  2. Choose an Output format, such as One per line or Comma + space.
  3. Type a domain into Only domains containing to keep only matching links, for example example.com.
  4. Pick the switches you need:
    • Remove duplicates keeps each URL once.
    • Sort A → Z orders the list.
    • Group by domain produces headed sections, one per site, with the busiest domain first.
    • Domains only returns just the host names, like example.com, instead of full URLs.
    • Add https:// to www. links turns bare www addresses into complete URLs.
    • Strip ?query and #hash removes everything after the path, which drops most tracking parameters.
  5. Check the summary for the number found, the number in the result and the number of domains, then Copy or Download.

Everything runs in your browser; nothing you paste is uploaded.

From a live web page

Browser developer tools can list every link on a page. Open the console (F12) and run:

[...document.links].map(a => a.href).join("\n")

This returns absolute URLs, resolved from relative links, which a text-based extractor cannot do. It is the best option for a page open in your browser. For many pages, crawling tools are more practical.

From page source

If you have saved HTML, paste the source into the extractor. Relative links like /about are not found, because they have no scheme or www. to recognise. If you need those, use the browser method above or convert the page first.

Spreadsheets

Google Sheets' REGEXEXTRACT can pull the first URL from each cell, and REGEXEXTRACT combined with SPLIT or Apps Script handles more. It suits data already in a sheet but becomes complex for multiple links per cell. Hyperlinked cells hide their URLs; in that case, a formula or script that reads the link target is needed.

Command line

grep -Eo '(https?|ftp)://[^ "<>]+' notes.txt | sort -u

This is fast and scriptable. It does not trim trailing punctuation, so expect some results ending in . or ), which you will need to clean.

Tips and troubleshooting

Tracking parameters

Links from newsletters and ads often carry parameters such as utm_source and click identifiers. Strip ?query and #hash removes them, but it also removes queries that matter, like search terms or page IDs. Check a few results before stripping in bulk. To add tracking parameters to your own links in a controlled way, use the UTM Builder.

Encoded characters

URLs may contain percent-encoded characters like %20. These are part of the URL and are kept as they are. If you need to read or change them, the URL Encoder decodes and encodes them.

If a long URL was wrapped onto two lines, for example in a plain-text email, the extractor will only capture the first part. Rejoin the lines first with Remove Line Breaks, choosing Nothing (join directly) for that section.

Email addresses are not URLs

mailto: links and addresses are not extracted as web links. Use the Email Extractor for those.

Extraction does not test whether links are live. For a list of your own pages, a site audit tool or crawler can check status codes.

Frequently asked questions

How do I extract all URLs from text?

Paste the text into a URL extractor, which finds every link that starts with http, https, ftp or www. Remove duplicates, then copy or download the list.

Paste the HTML source into the extractor to get absolute links, or run [...document.links].map(a => a.href) in the browser console to include relative links resolved to full URLs.

Yes. Turn on Domains only to get host names such as example.com, or Group by domain to see full links organised under each site.

How do I remove tracking parameters from URLs?

Turn on Strip ?query and #hash. It removes everything after the path, including utm_ parameters, so check that no important query values are lost.

Why does the extractor not trim a closing bracket?

If the URL contains an opening bracket, such as a Wikipedia page ending in _(disambiguation), the closing bracket belongs to the URL and is kept. Unbalanced closing brackets are trimmed.

Try it now: URL Extractor

Loading tool…