Pretty print xml (and json) in Python

Quick Python one-liner to prettify xml (and json too)

So that I don't forget... again.

from xml.dom import minidom

# from a string
minidom.parseString(xml_string).toprettyxml
            
Read more