HTML Editor type formatting with JS?

Hi all, I have a Rich Text Editor I have written for a client and one of the options is to view the source as HTML, which basically grabs the innerHTML of the iframe and places it in a div. The problem is that is just dumps a single line (since its now a string). Is there anyway to format that string as though you were looking at it inside an html editor (with tabs and divs on new lines etc etc). I could do it manually in a function but i thought someone may have already written a function or class to reformat strings as html. any ideas would be greatly appreciated :slight_smile: