html-torch is a library designed to clean up HTML by removing everything but the tags meaningful to Large Language Models (LLMs). It strips away unnecessary scripts, styles, attributes, and more to tidy up HTML content.
npm install html-torchHere's a basic example of how to use html-torch to clean up an HTML file:
import htmlTorch from 'html-torch';
const html = '<html>....</html>';
const { torchedHTML, summaryJSON } = await htmlTorch(html);
const { elements, selectors } = summaryJSON;
// html (Original) -> 1.4MB
// torchedHTML (Torched) -> 179KB
// elements (Summary JSON) -> 43KBFor more options and detailed usage, refer to the html-torch.ts file.
Before running this project locally, set up the Node.js version and install the necessary packages using the following commands:
nvm install
nvm use
npm installTo ensure everything is working correctly, you can run the tests using the following command:
npm testThis project is licensed under the MIT License - see the LICENSE file for details.
