1.0.1 โข Published 12 months ago
@mysticwillz/html-to-string v1.0.1
html-to-string
๐ชผ A tiny utility that strips HTML tags from a string and returns clean text.
โจ Features
- ๐ฉธ Lightweight โ No dependencies
- โก Fast and simple
- โ TypeScript support
- ๐ Ideal for frontend & backend use
๐ฆ Installation
npm i @mysticwillz/html-to-stringor
yarn add @mysticwillz/html-to-string๐ Usage
Basic Example
import { stripHTML } from "@mysticwillz/html-to-string";
const dirty = "<h1>Hello <em>World</em></h1>";
const clean = stripHTML(dirty);
console.log(clean); // "Hello World"๐ง API
stripHTML(html: string): string
| Param | Type | Description |
|---|---|---|
| html | string | String containing HTML content |
| โ | string | Clean string with tags removed |
๐งช Example Inputs
stripHTML("<p>This is <strong>important</strong></p>");
// โ "This is important"
stripHTML('<div><a href="#">Link</a></div>');
// โ "Link"
stripHTML("");
// โ ""๐ Project Structure
html-to-string/
โโโ src/
โ โโโ index.ts # Main function
โโโ dist/ # Compiled output
โโโ test.js # Example usage
โโโ package.json
โโโ README.md๐ License
MIT ยฉ 2025 Eze Williams Ezebuilo
๐ก Inspiration
This package was built to provide a fast, minimalist solution to convert HTML into plain readable text without unnecessary complexity.
๐ Contributing
Pull requests, suggestions, and ideas are welcome! Open an issue or submit a PR.