# html-urls

> Extract all href and src URLs from HTML markup for crawling, auditing, and link checks.

Latest version **2.5.5** (published 2026-08-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install html-urls
pnpm add html-urls
yarn add html-urls
bun add html-urls
```

## Health

**Score 55/100 (C)** — status: active.

Positive: no vulnerabilities; recently updated; high maintenance score.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 2.5.5 |
| Published | 2026-08-13 |
| First published | 2018-01-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 6 |
| Dependencies | 6 |
| Unpacked size | 10.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 12 |
| Author | Kiko Beats |
| Maintainers | kikobeats |
| Keywords | anchors, crawl, extract, href, html, links, parser, src, url, urls |

## Links

- npm: https://www.npmjs.com/package/html-urls
- Repository: https://github.com/Kikobeats/html-urls
- Issues: https://github.com/Kikobeats/html-urls/issues
- npm.io page: https://npm.io/package/html-urls

## Dependencies (6)

- [is-uri](https://npm.io/package/is-uri.md) ~1.2.14
- [lodash](https://npm.io/package/lodash.md) ~4.18.1
- [cheerio](https://npm.io/package/cheerio.md) ~1.2.0
- [matcher](https://npm.io/package/matcher.md) ~4.0.0
- [is-url-http](https://npm.io/package/is-url-http.md) ~2.3.13
- [@metascraper/helpers](https://npm.io/package/@metascraper/helpers.md) ~5.55.0

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 2.5.5 (latest) — 2026-08-13
- 2.5.4 — 2026-08-11
- 2.5.3 — 2026-08-03
- 2.5.2 — 2026-08-03
- 2.5.1 — 2026-08-02
- 2.5.0 — 2026-07-30
- 2.4.68 — 2026-07-30
- 2.4.67 — 2026-06-09
- 2.4.66 — 2025-06-23
- 2.4.65 — 2025-04-20
- 2.4.64 — 2025-04-20
- 2.4.63 — 2025-03-19
- 2.4.62 — 2025-01-13
- 2.4.61 — 2025-01-13
- 2.4.60 — 2024-08-12
- … 96 more at https://npm.io/package/html-urls/versions

## README

# html-urls

![Last version](https://img.shields.io/github/tag/Kikobeats/html-urls.svg?style=flat-square)
[![Coverage Status](https://img.shields.io/coveralls/Kikobeats/html-urls.svg?style=flat-square)](https://coveralls.io/github/Kikobeats/html-urls)
[![NPM Status](https://img.shields.io/npm/dm/html-urls.svg?style=flat-square)](https://www.npmjs.org/package/html-urls)

> Get all URLs from a HTML markup. It's based on [W3C link checker](https://github.com/w3c/node-linkchecker).

## Install

```bash
$ npm install html-urls --save
```

## Usage

```js
const got = require('got')
const htmlUrls = require('html-urls')

;(async () => {
  const url = process.argv[2]
  if (!url) throw new TypeError('Need to provide an url as first argument.')
  const { body: html } = await got(url)
  const links = htmlUrls({ html, url })

  links.forEach(({ url }) => console.log(url))

  // => [
  //   'https://microlink.io/component---src-layouts-index-js-86b5f94dfa48cb04ae41.js',
  //   'https://microlink.io/component---src-pages-index-js-a302027ab59365471b7d.js',
  //   'https://microlink.io/path---index-709b6cf5b986a710cc3a.js',
  //   'https://microlink.io/app-8b4269e1fadd08e6ea1e.js',
  //   'https://microlink.io/commons-8b286eac293678e1c98c.js',
  //   'https://microlink.io',
  //   ...
  // ]
})()
```

It returns the following structure per every value detect on the HTML markup:

#####  value
Type: `<string>`

The original value.

#####  url
Type: `<string|undefined>`

The normalized URL, if the value can be considered an URL.

#####  uri
Type: `<string|undefined>`

The normalized value as URI.

<br/>

See [examples](/examples) for more!

## API

### htmlUrls([options])

#### options

##### html

Type: `string`<br>
Default: `''`

The HTML markup.

##### url

Type: `string`<br>
Default: `''`

The URL associated with the HTML markup.

It is used for resolve relative links that can be present in the HTML markup.

##### whitelist

Type: `array`<br>
Default: `[]`

A list of links to be excluded from the final output. It supports regex patterns.

See [matcher](https://github.com/sindresorhus/matcher#matcher) for know more.

##### removeDuplicates

Type: `boolean`<br>
Default: `true`

Remove duplicated links detected over all the HTML tags.

## Related

- [xml-urls](https://github.com/Kikobeats/xml-urls) – Get all urls from a Feed/Atom/RSS/Sitemap xml markup.
- [css-urls](https://github.com/Kikobeats/css-urls) – Get all URLs referenced from stylesheet files.

## License

**html-urls** © [Kiko Beats](https://kikobeats.com), released under the [MIT](https://github.com/Kikobeats/html-urls/blob/master/LICENSE.md) License.<br>
Authored and maintained by Kiko Beats with help from [contributors](https://github.com/Kikobeats/html-urls/contributors).

> [kikobeats.com](https://kikobeats.com) · GitHub [@Kiko Beats](https://github.com/Kikobeats) · X [@Kikobeats](https://x.com/Kikobeats)

---
_Source: https://npm.io/package/html-urls · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
