fuzzii fuzzii - 3 days ago 4x
Javascript Question

Typescript: print string as HTML to the terminal?

I know this seems like a very basic question, but I haven't been able to find the answer.

I'm reading from a local file using typescript. I then want to use console.log to print the file contents to the terminal. However, the file is a HTML file, so I'm wondering if I can render the tags, before printing to the terminal.

My progress so far, has just involved printing the tags to the terminal with the content.

Is it possible to render the HTML elements before the content is printed to the terminal?


You can't render HTML in the browser's console. What you can do is, you can style the output. See this answer for more information.


console.log("%cThis will be formatted with large, blue text", "color: blue; font-size: x-large");