- Published on
How to Validate HTML Strings in JavaScript
- Authors
- Name
- Ashik Nesin
- @AshikNesin
If you have a string and want to validate whether the given string is HTML or not.
Then is-html NPM package might be a good choice for you.
With this package, you can validate it in a single line. And here is how to do it:
Dependency
npm install is-html
Snippet
import isHtml from 'is-html';
isHtml('<p>Hello World</p>');
//👉 true
isHtml('Something else');
//👉 false
Happy validating HTML!