JSFiddle - React, Tailwind, and code Playground

HTML

<div id="content" style="width:300px;height:100px;">

</div>

CSS

pre{
margin-left:20px;
}

JavaScript

var string = "Some normal text <html><body><div>This is the html </div> </body></html> more text<p>more html content</p> yet more normal text";
var holder = $('<div>').html(string);
holder.children().wrap('<pre>');
//Print result
$('#content').html(holder.html());