# html-get

> Get the HTML from any website, fine-tuned for correction & speed

Latest version **2.27.23** (published 2026-11-23) · MIT license · 0 weekly downloads

## Install

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

Provides the command `html-get`.

## Health

**Score 65/100 (B)** — status: active.

Positive: has types; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 2.27.23 |
| Published | 2026-11-23 |
| First published | 2018-06-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >= 24 |
| Dependencies | 20 |
| Unpacked size | 86.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| GitHub stars | 102 |
| Author | Kiko Beats |
| Maintainers | kikobeats |
| Keywords | audio, fetch, get, got, headless, html, image, markup, pdf, prerender, request, video |

## Links

- npm: https://www.npmjs.com/package/html-get
- Repository: https://github.com/microlinkhq/html-get
- Homepage: https://nicedoc.com/microlinkhq/html-get
- Issues: https://github.com/microlinkhq/html-get/issues
- npm.io page: https://npm.io/package/html-get

## Dependencies (20)

- [mri](https://npm.io/package/mri.md) ~1.2.0
- [unpdf](https://npm.io/package/unpdf.md) ~2.2.0
- [lodash](https://npm.io/package/lodash.md) ~4.18.1
- [cheerio](https://npm.io/package/cheerio.md) ~1.2.0
- [execall](https://npm.io/package/execall.md) ~2.0.0
- [p-retry](https://npm.io/package/p-retry.md) ~4.6.0
- [html-urls](https://npm.io/package/html-urls.md) ~2.5.0
- [tinyspawn](https://npm.io/package/tinyspawn.md) ~1.5.7
- [top-sites](https://npm.io/package/top-sites.md) ~1.1.224
- [html-encode](https://npm.io/package/html-encode.md) ~2.1.15
- [content-type](https://npm.io/package/content-type.md) ~3.1.0
- [debug-logfmt](https://npm.io/package/debug-logfmt.md) ~1.4.12
- [p-cancelable](https://npm.io/package/p-cancelable.md) ~2.1.0
- [css-url-regex](https://npm.io/package/css-url-regex.md) ~4.0.0
- [@kikobeats/got](https://npm.io/package/@kikobeats/got.md) ~11.8.8
- [is-html-content](https://npm.io/package/is-html-content.md) ~1.0.0
- [is-local-address](https://npm.io/package/is-local-address.md) ~2.4.4
- [@kikobeats/time-span](https://npm.io/package/@kikobeats/time-span.md) ~1.0.13
- [@metascraper/helpers](https://npm.io/package/@metascraper/helpers.md) ~5.58.4
- [null-prototype-object](https://npm.io/package/null-prototype-object.md) ~1.2.7

## Alternatives

- [@cantoo/pdf-lib](https://npm.io/package/@cantoo/pdf-lib.md) — 297.9K weekly downloads
- [datatables.net-buttons](https://npm.io/package/datatables.net-buttons.md) — 200.1K weekly downloads
- [@ckeditor/ckeditor5-export-pdf](https://npm.io/package/@ckeditor/ckeditor5-export-pdf.md) — 167.0K weekly downloads
- [scanbot-web-sdk](https://npm.io/package/scanbot-web-sdk.md) — 15.0K weekly downloads
- [@syncfusion/ej2-angular-pdfviewer](https://npm.io/package/@syncfusion/ej2-angular-pdfviewer.md) — 8.8K weekly downloads

## Recent versions

- 2.27.23 (latest) — 2026-11-23
- 2.22.0-1 (prerelease) — 2025-04-12
- 2.27.22 — 2026-11-21
- 2.27.21 — 2026-11-19
- 2.27.20 — 2026-11-17
- 2.27.19 — 2026-11-06
- 2.27.18 — 2026-11-02
- 2.27.17 — 2026-10-30
- 2.27.16 — 2026-10-29
- 2.27.15 — 2026-10-28
- 2.27.14 — 2026-10-28
- 2.27.13 — 2026-10-27
- 2.27.12 — 2026-10-19
- 2.27.11 — 2026-10-15
- 2.27.10 — 2026-10-13
- … 361 more at https://npm.io/package/html-get/versions

## README

<div align="center">
  <img src="https://github.com/microlinkhq/cdn/raw/master/dist/logo/banner.png#gh-light-mode-only" alt="microlink logo">
  <img src="https://github.com/microlinkhq/cdn/raw/master/dist/logo/banner-dark.png#gh-dark-mode-only" alt="microlink logo">
  <br>
  <br>
</div>

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

> Get the HTML from any website, fine-tuned for correction & speed.

## Features

- Get HTML markup for any URL, including images, video, audio, pdf, or office documents (docx, xlsx, pptx, odt, rtf, epub).
- Block ads tracker or any non-necessary network subrequest.
- Handle unreachable or timeout URLs gracefully.
- Ensure HTML markup is appropriately encoded.

**html-get** takes advantage of [puppeteer](https://github.com/GoogleChrome/puppeteer) headless technology when is needed, such as client-side apps that needs to be prerender.

## Install

```bash
$ npm install browserless puppeteer html-get --save
```

## Usage

```js
const createBrowserless = require('browserless')
const getHTML = require('html-get')

// Spawn Chromium process once
const browserlessFactory = createBrowserless()

// Kill the process when Node.js exit
process.on('exit', () => {
  console.log('closing resources!')
  browserlessFactory.close()
})

const getContent = async url => {
  // create a browser context inside Chromium process
  const browserContext = browserlessFactory.createContext()
  const getBrowserless = () => browserContext
  const result = await getHTML(url, { getBrowserless })
  // close the browser context after it's used
  await getBrowserless((browser) => browser.destroyContext())
  return result
}

getContent('https://example.com')
  .then(content => {
    console.log(content)
    process.exit()
  })
  .catch(error => {
    console.error(error)
    process.exit(1)
  })
```

### Command Line

```
$ npx html-get https://example.com
```

## API

### getHTML(url, [options])

#### url

*Required*<br>
Type: `string`

The target URL for getting the HTML markup.

#### options

##### encoding

Type: `string`
Default: `'utf-8'`

It ensures the HTML markup is encoded to the encoded value provided.

The value will be passes to [`html-encode`](https://github.com/kikobeats/html-encode) 

##### getBrowserless

*Required*<br>
Type: `function`

A function that should return a [browserless](https://browserless.js.org/) instance to be used for interact with puppeteer:

##### getMode

Type: `function`

It determines the strategy to use based on the `url`, being the possibles values `'fetch'` or `'prerender'` .

##### getTemporalFile

Type: `function`

It creates a temporal file.

##### gotOpts

Type: `object`

It passes configuration object to [got](https://www.npmjs.com/package/got) under `'fetch'` strategy.

##### headers

Type: `object`

Request headers that will be passed to fetch/prerender process.

##### mutool

Type: `function`|`boolean`<br>
Default: `source code`

It returns a function that receives that executes [mutool](https://mupdf.com/) binary for turning PDF files into HTML markup.

It can explicitly disabled passing `false`.

A custom function receives the arguments and `{ signal, timeout }`: `timeout` is what is left of the fetch timeout, and `signal` aborts when the fetch is canceled. The default runner kills mutool with `SIGKILL` on either.

##### pandoc

Type: `function`|`boolean`<br>
Default: `source code`

It returns a function that executes the [pandoc](https://pandoc.org/) binary for turning office documents (docx, xlsx, pptx, odt, rtf, epub) into HTML markup.

The format is resolved from the response content-type, falling back to the URL extension.

It can be explicitly disabled passing `false`.

A custom function receives `(format, filepath, { signal, timeout })`, with the same meaning as for `mutool`. The default runner kills pandoc with `SIGKILL` on either, so a conversion never outlives its fetch: pandoc has no limit of its own, and a 4.5MB spreadsheet once took it 34s and 10.9GB.

##### prerender

Type: `boolean`|`string`<br>
Default: `'auto'`

Enable or disable prerendering as mechanism for getting the HTML markup explicitly.

The value `auto` means that that internally use a list of websites that don't need to use prerendering by default. This list is used for speedup the process, using `fetch` mode for these websites.

See [getMode parameter](#getMode) for know more.

##### puppeteerOpts

Type: `object`

It passes coniguration object to [puppeteer](https://www.npmjs.com/package/puppeteer) under `'prerender'` strategy.

##### rewriteUrls

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

When is `true`, it will be rewritten CSS/HTML relatives URLs present in the HTML markup into absolutes.

##### rewriteHtml

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

When is `true`, it will rewrite some common mistake related with HTML meta tags.

##### serializeHtml

It determines how HTML should be serialied before returning.

It's serialized `$ => ({ html: $.html() })` by default.

## License

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

> [microlink.io](https://microlink.io) · GitHub [microlinkhq](https://github.com/microlinkhq) · X [@microlinkhq](https://x.com/microlinkhq)

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