Skip to content

Instantly share code, notes, and snippets.

@Sanchithasharma
Last active February 5, 2021 10:43
Show Gist options
  • Save Sanchithasharma/7e193212b414a06f89be3cfb72b6a882 to your computer and use it in GitHub Desktop.
Save Sanchithasharma/7e193212b414a06f89be3cfb72b6a882 to your computer and use it in GitHub Desktop.
Convert HTML to plain text using html-to-text package
const { htmlToText } = require('html-to-text');
const text = htmlToText('<div>Nope Its not Ashton Kutcher. It is Kevin Malone. <p>Equally Smart and equally handsome</p></div>', {
wordwrap: 130
});
console.log(text); // expected result:
// Nope Its not Ashton Kutcher. It is Kevin Malone.
// Equally Smart and equally handsome
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment