# html-to-formatted-text

> Convert HTML to formatted text

Latest version **2.7.0** (published 2019-05-29) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 2.7.0 |
| Published | 2019-05-29 |
| First published | 2018-07-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 46.3 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 10 |
| Author | Luke Scott |
| Maintainers | lukeaus |
| Keywords | html, formatted, text |

## Links

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

## Dependencies (1)

- [striptags](https://npm.io/package/striptags.md) 3.1.1

## Alternatives

- [@tsparticles/shape-image](https://npm.io/package/@tsparticles/shape-image.md) — 303.7K weekly downloads
- [@tsparticles/shape-line](https://npm.io/package/@tsparticles/shape-line.md) — 233.7K weekly downloads
- [stringify-attributes](https://npm.io/package/stringify-attributes.md) — 58.6K weekly downloads
- [mobile-drag-drop](https://npm.io/package/mobile-drag-drop.md) — 46.3K weekly downloads
- [@comunica/actor-rdf-parse-html](https://npm.io/package/@comunica/actor-rdf-parse-html.md) — 29.2K weekly downloads

## Recent versions

- 2.7.0 (latest) — 2019-05-29
- 2.6.2 — 2019-05-29
- 2.6.1 — 2019-05-29
- 2.6.0 — 2018-07-26
- 2.5.0 — 2018-07-25
- 2.4.0 — 2018-07-25
- 2.3.0 — 2018-07-25
- 2.2.1 — 2018-07-25
- 2.2.0 — 2018-07-25
- 2.1.0 — 2018-07-24
- 2.0.0 — 2018-07-24
- 1.0.1 — 2018-07-24
- 1.0.0 — 2018-07-19

## README

# html-to-formatted-text

[![Tests](https://img.shields.io/travis/lukeaus/html-to-formatted-text/master.svg)](https://travis-ci.org/lukeaus/html-to-formatted-text)
[![Coverage](https://img.shields.io/codecov/c/github/lukeaus/html-to-formatted-text.svg)](https://codecov.io/gh/lukeaus/html-to-formatted-text)
[![MIT License](https://img.shields.io/npm/l/html-to-formatted-text.svg)](https://github.com/lukeaus/html-to-formatted-text/blob/master/LICENSE)
[![version](https://img.shields.io/npm/v/html-to-formatted-text.svg)](http://npm.im/html-to-formatted-text)
[![downloads](https://img.shields.io/npm/dm/html-to-formatted-text.svg)](http://npm-stat.com/charts.html?package=html-to-formatted-text&from=2018-07-24)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)

## What

Converts HTML to formatted plain text.

From:

`"<p>Some text.</p><p>More text.</p><div>Even more text.</div>"`

To:

```
Some text.

More text.

Even more text.
```

## Usage

### Node

### Installation

```bash
npm install --save html-to-formatted-text
```

```javascript
const htmlToFormattedText = require("html-to-formatted-text");
htmlToFormattedText("<p>foo</p><p>bar</p>"); // Output: "foo\nbar"
```

### ES6

```javascript
// ES6
import htmlToFormattedText from "html-to-formatted-text";
htmlToFormattedText("<p>foo</p><p>bar</p>"); // Output: "foo\nbar"
```

### Vanilla JS / UMD

```html
<!-- latest version -->
<script src="https://unpkg.com/html-to-formatted-text/dist/index.umd.min.js"></script>
<!-- or for a specific version -->
<script src="https://unpkg.com/html-to-formatted-text@X.Y.Z/dist/index.umd.min.js"></script>
<script>
  document.addEventListener("DOMContentLoaded", function () {
    window.htmlToFormattedText('<p>foo</p><p>bar</p>') // Output: "foo\nbar"
  });
</script>
```

## Why

You might have HTML that you want to display as text.

One use case might be that a user adds HTML via an online editor [TinyMCE](https://www.tiny.cloud/) and you want to display this as plain text somewhere else.

## Contributing

- Create an issue on Github
- Fork project
- Make changes then use `npm run commit` to make commits
- Create a pull request

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