Skip to content

XML Formatting

Josh Johnson edited this page Apr 27, 2023 · 8 revisions

Format Ugly XML

After opening an XML document, use the Format Document command, use SHIFT + ALT + F (CTRL + SHIFT + I on Linux, Option + Shift + F on Mac), or right-click the document and click Format Document. You can also highlight a subset of XML (as long as it is a valid, well-formed XML node) and perform the same actions.

v1.8.0+: You can format any document or selection as XML by using the Format as XML command.

💡 Pro Tip
By default, XML namespace attributes are each given their own line in the formatted XML.
Don't like how that looks? Set the xmlTools.splitXmlnsOnFormat setting to false in your user or workspace settings file.

Minify Formatted XML

If you feel the urge to make your XML ugly again, use the XML Tools: Minify XML command.

💡 Pro Tip
By default, your XML comments will remain intact when minifying XML.
To get rid of those comments, set the xmlTools.removeCommentsOnMinify setting to true in your user or workspace settings file.