Published on

How to Validate HTML Strings in JavaScript


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:


npm install is-html


import isHtml from 'is-html';

isHtml('<p>Hello World</p>');
//👉 true

isHtml('Something else');

//👉 false

Happy validating HTML!