# html-table-to-array

> Turns an HTML table -- with or without headers -- into an array of arrays.

Latest version **1.0.0** (published 2016-04-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install html-table-to-array
pnpm add html-table-to-array
yarn add html-table-to-array
bun add html-table-to-array
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2016-04-21 |
| First published | 2016-04-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Giovanni T. Parra |
| Maintainers | fiatjaf |
| Keywords | html, table, array, parse |

## Links

- npm: https://www.npmjs.com/package/html-table-to-array
- npm.io page: https://npm.io/package/html-table-to-array

## Alternatives

- [@lexical/table](https://npm.io/package/@lexical/table.md) — 3.0M weekly downloads
- [mantine-datatable](https://npm.io/package/mantine-datatable.md) — 98.2K weekly downloads
- [react-native-collapsible-tab-view](https://npm.io/package/react-native-collapsible-tab-view.md) — 70.6K weekly downloads
- [@handsontable/vue3](https://npm.io/package/@handsontable/vue3.md) — 16.1K weekly downloads
- [vuewordcloud](https://npm.io/package/vuewordcloud.md) — 7.2K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2016-04-21

## README

The full code for this package:

```javascript
module.exports = function HTMLTableToArray (element, withHeader /* defaults to false */) {
  element = typeof element === 'string' ? document.querySelector(element) : element

  var a = []
  var rows = element.querySelectorAll('tr')
  for (var i = 0; i < rows.length; i++) {
    var row = rows[i]
    var aa = []
    var cells = row.querySelectorAll(withHeader ? 'th,td' : 'td')
    for (var j = 0; j < cells.length; j++) {
      var cell = cells[j]
      aa.push(cell.innerText)
    }

    if (!withHeader) {
      // ignore header rows
      if (row.querySelectorAll('th').length > 1) continue
    }

    a.push(aa)
  }

  return a
}
```

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