Format a string as if it were an XML file

I’m writing a method that is generating the body of an XML file. The method returns a string, which I then pass to
const file = new Blob([content], {type: "text/xml"});
as the content variable. How can I get this string to format itself as a more readable format? Specifically, I’m looking for a way to auto-indent and add newlines wherever necessary as opposed to adding them manually.