Skip to main content
← All guides

6 min read

XML formatter: make an XML file readable, or turn it into an Excel table

By Quentin Delepierre, Salesforce Commerce Cloud consultant

Looking for an XML formatter, or wanting to “format an XML file”, means two things. For some people it means indenting it: an export sits on a single line and they want to read it. For others it means seeing it as a table, with one column per field, and being able to edit it. The two needs have different answers. Here are the free ways to indent, what Excel does on its own with an XML file, and the method to pick when you need a real table.

Got your own XML? Drop it in and see it as a table, free and with no account. For an Excel file you can edit and then rebuild into an XML that keeps its structure, a free account is all you need.

Transform a file

Simple Excel table, free with no account, for files up to 1 MB. File that rebuilds into XML: free account, 3 free credits, no credit card.

Download an example result (.xlsx)Example source XML

How do I format an XML file to read it, or to edit it in Excel?

“Formatting” an XML file means two things. To read it, indent it with a code editor and its “Format Document” command (Visual Studio Code needs an extension for XML), or open it in a browser: it's free, but it doesn't change the structure and doesn't give you a table. To edit it, you need a table, then a way back to the XML: Excel doesn't rewrite an XML file in the structure of your own file on its own, whereas ExcelifyXML puts one row per repeated element and one column per field, then rebuilds the XML, indented. The preview is free and needs no account; editing and rebuilding needs a free account and 1 credit.

The same XML, seen three ways

A small invented catalog with two products. First as an export often delivers it, on a single line; then indented, which is the same file laid out; then the table, where each product becomes a row.

The XML on a single line
<catalog><product id="P001"><name>Light jacket</name><price currency="EUR">89.00</price><color>blue</color></product><product id="P002"><name>Round-neck sweater</name><price currency="EUR">59.00</price><color>grey</color></product></catalog>
The same XML, indented
<catalog>
  <product id="P001">
    <name>Light jacket</name>
    <price currency="EUR">89.00</price>
    <color>blue</color>
  </product>
  <product id="P002">
    <name>Round-neck sweater</name>
    <price currency="EUR">59.00</price>
    <color>grey</color>
  </product>
</catalog>
The table: one row per product
@id , name , price.@currency , price , color
P001 , Light jacket , EUR , 89.00 , blue
P002 , Round-neck sweater , EUR , 59.00 , grey

How do I indent an XML file for free to read it?

If you only want to understand what an XML file contains, you don't need Excel. Two free options:

  • A browser: open the file in a browser window. Without a style sheet, it shows the content of the XML (MDN describes it as the raw XML); depending on the browser you get a tree or the text as it is. Handy for a quick look, with no guarantee of indentation.
  • A code editor, with its “Format Document” command. In Visual Studio Code, the default shortcut is Shift+Alt+F on Windows, ⇧⌥F on Mac and Ctrl+Shift+I on Linux (or the Command Palette, “Format Document”). Note: according to its documentation, VS Code has built-in formatters only for JavaScript, TypeScript, JSON, HTML and CSS. For XML you need to install an XML formatting extension. Other editors have their own command: look for “format” or “indent” in the menus.

What to know before indenting

  • Indenting adds spaces and line breaks between the tags. In an XML file where whitespace matters (text mixed with tags, for example), it can change the content: keep your original file.
  • Indenting doesn't change the structure and doesn't give you a table: you read better, but you still edit the file tag by tag.
  • An online formatter receives your file. For a client file, check what it does with it before you drop it there.

What does Excel do when you open an XML file?

In Excel, File › Open, then pick the XML file. According to Microsoft's help page, an “Open XML” box then offers three choices when the file references no style sheet:

  • “As an XML table”: Excel creates an XML table in a new workbook. If the file has no schema, Excel infers one.
  • “As a read-only workbook”: the data shows as a table, with the tags as headings. The file opens read-only, so you don't overwrite the original XML by accident, and no XML map can be used.
  • “Use the XML Source task pane”: the schema shows in the pane, and you drag elements onto the sheet to map them. If the file has no schema, Excel infers one.

What are the limits of opening an XML file in Excel?

  • XML maps and the XML Source pane: Microsoft states that only Excel for Windows offers XML mapping, which isn't in Excel for Mac or Excel for the web. On Mac, see the dedicated guide.
  • When the XML contains lists inside lists (products that each have several prices or a description per language), Excel's export to XML stops: this is the “list of lists” error.
  • Excel doesn't write an XML file in the structure of your own file from an arbitrary table: your fixes stay in the workbook.
  • An XML file opened “read-only” can be read, but not edited to be imported elsewhere.

How do I turn an XML file into an Excel table, edit it, and put it back into XML?

If reading isn't enough and you want to fix prices, descriptions or codes before re-importing the file, indenting doesn't help: you need a table, then a way back to the XML. That is what ExcelifyXML does: one row per repeated element (here, a product), one column per field or attribute, as in the table above.

  1. Drop your XML file on the Upload page (the file you edit and then rebuild into XML needs a free account; 3 credits are offered at sign-up). The free preview shows the row chosen, the number of rows and columns and the first rows of the table. No credit is used before you confirm. Without an account, you can already see the preview and, for a file of 1 MB or less, download a simple Excel table for free (without the structure: it can't be rebuilt into XML).
  2. Not the right row? Open “Not the right row?” under the preview and pick another tag: the preview updates, still without a credit.
  3. Confirm with “Transform to CSV — 1 credit”, then choose the Excel file (.xlsx) or the CSV.
  4. Edit the table in Excel, LibreOffice, Google Sheets or Numbers. Don't rename the headers: they say where each value goes back in the XML.
  5. Drop the saved file on the Rebuild page, which is free: you get the XML back with its original structure, attributes and element order. The rebuilt XML is written indented, two spaces per level: it is readable.

Which option to choose?

  • You only want to read an XML file on a single line: a browser, or a code editor with document formatting. Free, no Excel.
  • You want to look at the data as a table on Windows, without editing anything: File › Open in Excel, “as a read-only workbook”.
  • You want to edit the values and get back an XML file with the same structure, on Windows or on Mac: the ExcelifyXML method, with its free preview before any credit.

Drop your XML to see it as a table: the preview is free and needs no account, nothing is charged without your confirmation:

Transform a file