Format XML code in Eclipse Format XML code in Eclipse xml xml

Format XML code in Eclipse


Ctrl+Shift+F

Will do it for you, and you can configure it in

Window -> Preferences -> XML -> Xml Files -> Editor


As stated above, Ctrl+Shift+F will auto-format. However, by default Eclipse will split attributes in a naive way. If you're like me and prefer to have all the attributes on their own lines, go to Window→Preferences→XML→XML Files→Editor and check Split multiple attributes each on a new line.


You need to open the file using the XML Editor, swap to Source view and then do the Ctrl + Shift + F trick.