# html-email-to-text

> Convert html emails to (formatted) plain text

Latest version **1.0.4** (published 2016-10-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install html-email-to-text
pnpm add html-email-to-text
yarn add html-email-to-text
bun add html-email-to-text
```

## 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.4 |
| Published | 2016-10-22 |
| First published | 2016-10-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | Andreas Nilsson |
| Maintainers | nandreas |
| Keywords | email, email-text, formatter, html, html-to-text, text |

## Links

- npm: https://www.npmjs.com/package/html-email-to-text
- Repository: https://github.com/nandreas/html-email-to-text
- Homepage: https://github.com/nandreas/html-email-to-text#readme
- Issues: https://github.com/nandreas/html-email-to-text/issues
- npm.io page: https://npm.io/package/html-email-to-text

## Dependencies (1)

- [htmlparser2](https://npm.io/package/htmlparser2.md) ^3.9.2

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 1.0.4 (latest) — 2016-10-22
- 1.0.3 — 2016-10-22
- 1.0.2 — 2016-10-22
- 1.0.1 — 2016-10-22
- 1.0.0 — 2016-10-22

## README

# html-email-to-text
Convert html emails to (formatted) plain text

## Install
```
$ npm install --save html-email-to-text
```

## Usage
```js
const htmlToText = require('html-email-to-text');

htmlToText('Html as a string');
//=> Formatted plain text as a string
```
## Examples

### HTML input
```html
<!DOCTYPE html>
<head>
  <title>Subject line: Title will be uppercase</title>
</head>
<body>
	<table>
	  <tr>
	    <td>
	      <table>
	        <tr>
	          <td>
	            <table>
	              <tr>
	                <td>Hello there</td>
	              </tr>
	              <tr>
	                <td>email coder</td>
	              </tr>
	              <tr>
	                <td>this is an example of </td>
	              </tr>
	              <tr>
	                <td>html-email-to-text formatting</td>
	              </tr>
	            </table>
	          </td>
	        </tr>
	        <tr>
	        	<td>
	        		This email &nbsp;&nbsp;&nbsp;&nbsp; can be formatted in plain text too.
	        		&nbsp;&nbsp;&nbsp;&nbsp;
	        		<!-- whitespace and comments will be ignored -->
	        		It works with a <a href="/links">link</a> or <a href="/another-link">two</a>.
	        	</td>
	        </tr>
	        <tr>
	        	<td>
	        		If you wrap links around images it will use the alt text together with the link.
	        		<a href="/link-to-somewhere"><img src="image.jpg" alt="alt text"></a>
	        	</td>
	        </tr>
	      </table>
	    </td>
	  </tr>
	</table>
</body>
</html>
```

### Text output
```
SUBJECT LINE: TITLE WILL BE UPPERCASE

--------------------

Hello there email coder this is an example of html-email-to-text formatting

This email can be formatted in plain text too.

It works with a link [/links] or two [/another-link].

If you wrap links around images it will use the alt text together with the link.

alt text
[/link-to-somewhere]
```

## License
MIT © [Andreas Nilsson](http://github.com/NaNdreas)

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