Link (href) Extractor

Paste HTML source and pull out every link — all href URLs, deduplicated and listed one per line, ready to copy or download.

1,042 views

How It Works

Paste HTML source — view-source output, a saved .html file, or any copied snippet — and the tool hands that text to the browser's own HTML parser rather than a hand-written regular expression. That distinction matters more than it sounds. Real-world HTML is messy in ways a naive regex struggles with: an attribute can be wrapped in double quotes, single quotes, or no quotes at all (href=about.html is technically legal HTML), a tag can be self-closing or not, and tags can nest many levels deep, span multiple lines, or sit inside comments and <script> blocks that themselves contain angle brackets. A browser-grade parser has spent two decades absorbing every one of those edge cases, because it has to render whatever page it is handed however malformed the markup is — building the extractor on that same engine, instead of reinventing pattern matching for tags, is what makes it reliable on markup you did not author yourself, like a scraped competitor page or an old campaign export.

Once the parser has built a structural tree from the pasted markup, every <a> element's href is read directly as a property of that element rather than as raw text pulled from a string — which already sidesteps quoting quirks and stray angle brackets inside comments that could otherwise fool a pattern match. The resulting list of URLs is then deduplicated and written out one per line, ready to copy to the clipboard or download as a plain text file.

Concrete example: a page's HTML contains <a href='/pricing'>, <a href="https://example.com/blog">, and a bare <a href=mailto:[email protected]> with no quotes at all — three different quoting styles in three lines. A regex written to match href="..." would silently miss the single-quoted and unquoted cases; the parser reads all three identically, because to a browser they are simply attribute values regardless of how — or whether — they are quoted.

What You Should Know

  • Relative URLs such as /pricing or ../blog/post are extracted exactly as written, not resolved into full https://... addresses. Turning a relative path into an absolute URL requires knowing the page's base URL — normally the address the HTML was originally fetched from, or an explicit <base> tag — and a pasted snippet carries neither on its own.
  • The tool never fetches a URL by itself; it only reads the HTML you provide. That is a deliberate boundary: auditing a page's outbound links this way needs no server-side request from this site at all, only from whatever browser you already used to view or save the source.
  • mailto: and tel: links come through exactly like any other href, since the parser does not discriminate by scheme — anything sitting in an href attribute counts as a link worth listing.

Frequently Asked Questions

Does it fetch the page itself, or do I need the HTML?

You provide the HTML — paste view-source output, a saved .html file's content, or any HTML snippet. The tool never fetches URLs on its own (that would require a server request this site does not make).

Are relative links included, and are they turned into full URLs?

Relative links (e.g. /about or ../page.html) are extracted exactly as written in the source, never resolved to absolute URLs. Resolving them would require knowing the page's base URL — usually the address the HTML was fetched from — which a pasted snippet does not carry on its own.

Does it include mailto: and tel: links?

Yes — any href value is extracted regardless of scheme, since the parser reads the attribute itself rather than filtering by what kind of link it is.

Why parse with the browser's DOM engine instead of a regex — does it really matter?

It matters most on messy, real-world HTML. A regex tuned for one quoting style (say, double-quoted href="...") will silently miss single-quoted or unquoted attributes, self-closing variations, and hrefs buried in deeply nested or malformed markup. The DOM parser handles all of that the same way a browser would when rendering the page, because it is the same underlying engine.

Will it still catch links in minified or badly broken HTML?

In almost all cases, yes. Browsers are built to render pages that are far from perfectly formed — missing closing tags, inconsistent nesting, minified single-line markup — and the same tolerant parsing applies here, which is precisely the advantage over a strict regex that expects clean, well-formatted input.

Comments

No comments yet — be the first to write one!

Similar Tools