How do I get clean output with indented structure
HTML Tidy can do what you're wanting, but this is designed as text format, Configuration » Content authoring » Text formats which are used in fields rather than the whole site.

Is should be possible with some work to pass the entire theme though HTML Tidy