To get the entire document HTML as a string with JavaScript, we use the innerHTML property.
For instance, we write
const markup = document.documentElement.innerHTML;
console.log(markup);
to get the htmlk element with document.documentElement.
Then we get the innerHTML property to the markup of its content as a string.