The W3C defines an XML specification recommendation: http://www.w3.org/TR/REC-xml/

Since you've narrowed your question to XML formatting, there's no "universal" answer to how your XML should be formatted. Beyond conforming to whatever DTD or schema you happen to be dealing with, the importance of particular spacing/indentation of your tags lies with the people who will be dealing with your data.

If you're creating XML data to be sent across a network as part of a web service or some sort, then generally you're going to want to eliminate any unnecessary whitespace before transfer in order to optimize your data transfer rate. This means no line breaks, no indentation, no comments.

If your creating an XML document that others will be reading/modifying on a regular basis, then obviously you'll want to put some consideration into keeping the document readable. What constitutes "readable" is determined by everyone involved on that particular team or project.

Answer from Jeff L on Stack Overflow
๐ŸŒ
JetBrains
jetbrains.com โ€บ help โ€บ idea โ€บ settings-code-style-xml.html
Code Style. XML | IntelliJ IDEA Documentation
August 6, 2026 - Use this page to configure formatting options for XML files. When you change these settings, the Preview pane shows how this will affect your code.
๐ŸŒ
Google
google.github.io โ€บ styleguide โ€บ xmlstyle.html
Google XML Document Format Style Guide
The compact syntax is quite easy to read and learn, and can be converted one-to-one to and from the XML syntax when necessary. Schematron handles arbitrary cross-element and cross-attribute constraints nicely.] Schemas SHOULD use the "Salami Slice" style (one rule per element).
๐ŸŒ
Nuxeo
doc.nuxeo.com โ€บ corg โ€บ xml-or-xml-like-files-code-style
XML or XML-like files code style | Nuxeo Documentation
3 weeks ago - Eclipse should be configured to use spaces (not tabs) and an indentation of 2 spaces is used for XML-like code.
Top answer
1 of 1
8
  • Intellij IDEA 2017.3 has got new project code style settings format. Now all code style settings are located under <PROJECT_ROOT>/.idea/codeStyles directory with the ultimate intention to support multiple project code styles linked to different scopes. New code style settings format is also cleaner and contains all code style settings properly grouped per language. Some old legacy Java, HTML settings previously stored without any language tag are moved to "JavaCodeStyleSettings", "HTMLCodeStyleSettings" etc. respectively.

  • The old .idea/codeStyleSettings.xml is imported into two new files: .idea/codeStyles/codeStyleConfig.xml containing a link to preferred project code style and .idea/codeStyles/Project.xml with code style settings for different languages. The latter is optional and created only if there are non-default settings. If .idea directory is under version control, both files can be added to VCS too. The old codeStyleSettings.xml is kept for backwards compatibility.


Original answer (now obsolete):

  • .idea/codeStyleSettings.xml stores the project specific code style that is for sharing with the project so that all the team members have the same code style applied automatically for this specific project. Check this answer for details.

  • .idea/codeStyles/codeStyleConfig.xml is used to override the default project code style. By default it contains <option name="USE_PER_PROJECT_SETTINGS" value="true" /> so that project specific configuration from .idea/codeStyleSettings.xml is used. If you switch your code style settings to use a scheme stored in the IDE instead of the project scheme, this file will store your choice.

  • IntelliJ IDEA also has support for .editorconfig which will have the priority and override IDE and project scheme by default. Check the documentation for more details.

  • codeStyle.xml in the project root is for Eclipse IDE and is not used by IntelliJ IDEA. It can be probably used by IntelliJ IDEA as well, if you have Eclipse Code Formatter plug-in installed and configured accordingly.

๐ŸŒ
Xwiki
dev.xwiki.org โ€บ xwiki โ€บ bin โ€บ view โ€บ Community โ€บ CodeStyle โ€บ XmlCodeStyle
XML Code Style - XWiki Development Zone
January 12, 2018 - There is no XML format profile in Eclipse, but the config is easy to find: Windows -> Preferences -> XML -> Editor:
Find elsewhere
๐ŸŒ
JetBrains
jetbrains.com โ€บ help โ€บ idea โ€บ configuring-code-style.html
Code style schemes | IntelliJ IDEA Documentation
1 month ago - You can export both project-level and IDE-level schemes in the IntelliJ IDEA code style XML, Eclipse XML Profile, or EditorConfig format (if the EditorConfig plugin is enabled).
๐ŸŒ
W3C
w3.org โ€บ Style โ€บ styling-XML.en.html
How to add style to XML
In this case the type="text/css" attribute must be present, otherwise the browser (or other program) has to guess the style sheet language. The xml-stylesheet PI now points not to an external style sheet, but to an element of the document itself. That element is identified by an id attribute that serves as the target of the link.
๐ŸŒ
Teleport
goteleport.com โ€บ home โ€บ resources โ€บ tools โ€บ xml beautifier | instantly format & beautify xml
XML Beautifier | Instantly Format & Beautify XML | Teleport
Configuration options allow you ... coding style. Common settings include indent size, quote character, line break type, and maximum line length. The easiest way to beautify XML is to use one of the many online tools available.
๐ŸŒ
JetBrains
jetbrains.com โ€บ help โ€บ rider โ€บ Settings_Code_Style_XML.html
Code Style. XML | JetBrains Rider Documentation
April 21, 2026 - Use this page to configure formatting options for XML files. When you change these settings, the Preview pane shows how this will affect your code.
๐ŸŒ
JetBrains
jetbrains.com โ€บ help โ€บ phpstorm โ€บ settings-code-style-xml.html
Code Style. XML | PhpStorm Documentation
April 21, 2026 - Use this page to configure formatting options for XML files. When you change these settings, the Preview pane shows how this will affect your code.
๐ŸŒ
Wikipedia
en.wikipedia.org โ€บ wiki โ€บ XML
XML - Wikipedia
4 days ago - The infoset is commonly used in the specifications of XML languages, for convenience in describing constraints on the XML constructs those languages allow. XSL (Extensible Stylesheet Language) is a family of languages used to transform and render XML documents, split into three parts:
๐ŸŒ
JetBrains
jetbrains.com โ€บ help โ€บ webstorm โ€บ settings-code-style-xml.html
Code Style. XML | WebStorm Documentation
Use this page to configure formatting options for XML files. When you change these settings, the Preview pane shows how this will affect your code.
๐ŸŒ
JetBrains
jetbrains.com โ€บ help โ€บ resharper โ€บ Code_Style_Assistance_in_XML.html
Code Style Assistance in XML | ReSharper Documentation
February 11, 2024 - ReSharper stores formatting preferences using the mechanism of shared settings. You can configure formatting rules in options pages under the Code Editing | XML | Formatting Style group.
๐ŸŒ
W3Schools
w3schools.com โ€บ xml
XML Tutorial
Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP, Bootstrap, Java, XML and more.