XML to CSV: how to convert a product feed, and back
When a seller needs XML to CSV or CSV to XML, why product XML is hard to flatten, the rules a free converter applies and the feed file formats Google accepts.
On this page
In short
- A product feed in XML holds nested elements, repeated elements, attributes and namespace prefixes such as g:, and a CSV table has a place for none of them.
- Central's free product file converter turns nested fields into dotted column names such as shipping.country and joins repeated values with a vertical bar; the file is read in the browser and not uploaded.
- Google Merchant Center accepts product files as tab-delimited .txt or .tsv files and as .xml files in RSS 2.0 or Atom 1.0, each up to 4 GB (as of November 2026).
- In a Google XML feed, every attribute from Google's namespace needs the g: prefix and the declaration xmlns:g="http://base.google.com/ns/1.0", or Google ignores the attribute and its value.
- Google lists saving a file in an encoding other than UTF-8 or UTF-16 among the common reasons a product file fails to process.
- OpenAI's product feed schema for ChatGPT gives formatting rules for CSV, TSV and JSONL files, with each complete record on one line in a JSONL file.
Which direction you need#
The source decides the format you get, the destination decides the format you need. Both directions come up in the same shop:
| Situation | You have | You need |
|---|---|---|
| A supplier or distributor sends its catalog as XML | XML | CSV or Excel for your shop's import |
| A price comparison site or a feed plugin writes your listings as XML and you want to check them | XML | A table you can sort and filter |
| A channel asks for an XML feed and your shop exports CSV | CSV | XML in the channel's schema |
| You have a Google feed and want to send products to ChatGPT | XML or tab-delimited text | CSV, TSV or JSON lines |
People work in tables; many systems write XML. The product file converter near the top of this page does both directions in your browser. The rest of this page explains what happens to your data on the way, so that you can check the result. What to do with a supplier's file once it is a table is covered in product data onboarding.
Why product XML is hard to flatten#
A CSV file is a grid: one row per product, one cell per value. XML is a tree. Four things in that tree have no place in a grid:
| In the XML | Example | The problem in a table |
|---|---|---|
| Nested elements | <g:shipping> holding <g:country>, <g:service> and <g:price> | One element holds three values |
| Repeated elements | Two <g:additional_image_link> elements | One name, several values |
| Attributes | <link href="https://www.northpeak.example/stove"/> in an Atom feed | The value sits inside the tag, not between two tags |
| Namespaces | The g: in <g:price> | The same field can arrive as price or as g:price |
A namespace says whose vocabulary an element belongs to. The W3C's Namespaces in XML identifies a namespace by a URI; the prefix is only a placeholder for it. A Google feed declares xmlns:g="http://base.google.com/ns/1.0". Google's RSS 2.0 specification says attributes from its namespace must carry the prefix, or they and their values are ignored. RSS itself brings three elements at item level: title, link and description.
Here is one product from a Google feed, a Northpeak camping stove with two extra images and a shipping rate:
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:g="http://base.google.com/ns/1.0">
<channel>
<title>Northpeak</title>
<link>https://www.northpeak.example</link>
<description>Northpeak product feed</description>
<item>
<g:id>NP-CS-01</g:id>
<title>Northpeak Ridge Camping Stove, 1 Burner</title>
<link>https://www.northpeak.example/ridge-stove</link>
<g:price>59.00 USD</g:price>
<g:availability>in_stock</g:availability>
<g:image_link>https://www.northpeak.example/img/stove.jpg</g:image_link>
<g:additional_image_link>https://www.northpeak.example/img/stove-side.jpg</g:additional_image_link>
<g:additional_image_link>https://www.northpeak.example/img/stove-in-use.jpg</g:additional_image_link>
<g:shipping>
<g:country>US</g:country>
<g:service>Standard</g:service>
<g:price>6.90 USD</g:price>
</g:shipping>
</item>
</channel>
</rss>And the same product as CSV, the way the converter writes it:
id,title,link,price,availability,image_link,additional_image_link,shipping.country,shipping.service,shipping.price
NP-CS-01,"Northpeak Ridge Camping Stove, 1 Burner",https://www.northpeak.example/ridge-stove,59.00 USD,in_stock,https://www.northpeak.example/img/stove.jpg,https://www.northpeak.example/img/stove-side.jpg | https://www.northpeak.example/img/stove-in-use.jpg,US,Standard,6.90 USDThree things happened. The g: prefix is gone. The two extra images share one cell, joined with a vertical bar. The shipping block became three columns with dotted names. The title is in double quotes because it contains a comma. The feed's own title, link and description in the channel block describe the feed, not a product, so they are not in the table.
The rules the free converter applies#
- It reads the file in your browser. CSV and TSV with a comma, semicolon, tab or vertical bar as the separator (it picks the one that occurs most in the first lines), Excel workbooks (.xlsx, the first sheet), JSON, JSON lines and XML. Nothing is uploaded.
- It finds the product elements. In an RSS feed these are the
itemelements, in an Atom feed theentryelements. In other XML it takes the element with child elements that repeats most often. - Namespace prefixes are dropped.
g:pricebecomes the columnprice. - Nested fields become dotted column names.
g:countryinsideg:shippingbecomesshipping.country. - Repeated values are joined with a vertical bar. Two image elements become one cell with
|between the links. - It reads element text, not attributes. A value that exists only as an attribute, such as the
hrefof an Atomlink, does not arrive in the table. Look for columns that came out empty. - It writes what you pick. CSV with commas or semicolons, TSV, Excel, JSON, JSON lines, plain XML, a Google feed as XML, or a Markdown table. In CSV output, a value that contains the separator, a double quote or a line break is put in double quotes.
CSV to XML: the way back#
When a channel wants XML and your shop exports a table, load the table and save it as "Google feed XML". The converter then writes an RSS 2.0 file with the g: namespace declared:
- Every row becomes one
item. - Every column becomes one element with the
g:prefix.title,linkanddescriptionstay without it. - A cell with values joined by
|becomes one element per value, which is how Google wants extra images in XML. - Empty cells are left out, and
&,<and>are escaped.
The column names must already be Google's, as listed in Google's product data specification. For shop exports, the converter has presets that rename columns: see the guides to the Shopify product CSV and the WooCommerce product CSV.
Two things the converter does not do on the way back. A dotted column such as shipping.country is not rebuilt into a nested g:shipping block, so set shipping in Merchant Center or write that block yourself. And the channel block gets a title only, while Google's sample file also gives the feed a link and a description; add them before you submit the file.
The plain "XML" output is for systems that take generic XML: a products root, one product element per row and one element per column.
The file formats Google Merchant Center accepts#
As of November 2026, Google's page Create a product file for Merchant Center names two kinds of product file: a tab-delimited spreadsheet or XML.
| Format | Extension | What Google states |
|---|---|---|
| Tab-delimited text | .txt, .tsv | The first line holds the attribute names, then one product per line, values separated by tabs |
| XML | .xml | RSS 2.0 or Atom 1.0; the file name must end in .xml |
| Compressed | .gz, .zip, .bz2 | Must contain a .txt or .xml file; Google's troubleshooting page adds: exactly one file per archive, smaller than 500 MB |
| Not accepted | .xls, .html | Google does not allow .xls files and names .html, .pdf and directly uploaded .xlsx files as formats that stop processing |
More rules from the same pages:
- Size. A product file can be up to 4 GB.
- Encoding. Google lists an encoding other than UTF-8 or UTF-16 among the common processing errors.
- No extension. A file name without an extension is processed as tab-delimited.
- CSV. A
.csvextension is not on the list. Google's price attribute page does head its text example "Text (TSV or CSV) data sources", but the file pages document tabs. Save a table as tab-delimited text. - Several values in a text file. Google's page on tab-delimited data sources separates repeated values with commas and sub-attributes with colons. Extra images are up to 10 links, separated by commas in a text file and written as repeated elements in XML. After converting XML to a text file for Google, replace the vertical bars between image links with commas.
- Inside a value. No tabs or line breaks inside a value and no trailing tabs in a text file; no capital letters in XML attribute names.
How to set a file up in Merchant Center and keep it current is the subject of the guides to the Google Shopping feed and to product feed management.
Encoding and delimiter pitfalls#
| Pitfall | What goes wrong | What to do |
|---|---|---|
| Encoding | Accents and umlauts turn into odd characters | Save as UTF-8. The XML specification obliges every XML processor to read UTF-8 and UTF-16. A file in another encoding must say so in its first line. |
| Byte order mark | An invisible mark sits before the first character of the file | The XML specification allows it in UTF-8 files and requires it in UTF-16 files. RFC 8259 says JSON sent between systems must not start with one. If an import cannot find the first column, look for this mark. The converter removes it when it reads a CSV. |
| Semicolons | A whole row lands in one column | Excel takes its list separator from the Windows region settings, says Microsoft. Pick the separator the destination wants when you save. |
| Decimal comma | 59,00 splits into two cells in a comma-separated file, or the price is refused | Write prices with a period. Google's price examples read 15.00 USD: a number, then the ISO 4217 currency code. |
| Quotes | A title with a comma or an inch mark breaks the row | RFC 4180 puts fields with commas, line breaks or double quotes in double quotes and doubles a quote inside a field. |
& and < in XML | The file cannot be read at all | The XML specification allows both only as markup. Write & and <. Google's troubleshooting page says the same about &. |
| Barcodes as numbers | Leading zeros vanish, long numbers show as 1.23E+15 | Microsoft says Excel removes leading zeros and converts large numbers to scientific notation. Format the column as text before the data goes in. |
How to check the result#
- Count. The table has as many rows as the XML has product elements, and the XML you wrote has as many items as the table has rows.
- Open the file in a text editor, not by double-click in a spreadsheet program, and look at the first three lines: header, separator, quotes.
- Check the IDs. Every row has one and no ID appears twice.
- Check the barcodes. Paste the column into the GTIN check digit calculator, which checks a whole column at once.
- Look at cells with a vertical bar. Decide what the destination wants there: commas, repeated elements or separate columns.
- Run the file through a checker. The product feed checker reads the converted file and checks it against Google's, Microsoft's or ChatGPT's feed rules.
A file that passes a format check can still carry weak data. How to measure that is covered in product data quality.
JSON and JSON lines for ChatGPT's feed#
OpenAI's product feed schema gives formatting rules for CSV, TSV and JSONL files. A JSON lines file has one complete record per line and no surrounding array, and lists are real arrays. A shortened record:
{"item_id":"NP-CS-01","title":"Northpeak Ridge Camping Stove, 1 Burner","price":"59.00 USD","target_countries":["US"],"additional_image_urls":["https://www.northpeak.example/img/stove-side.jpg"]}In a CSV or TSV file the same structures go into one cell: OpenAI asks for a list of image links as one comma-separated string and for objects serialized as JSON. Text is UTF-8, identifiers stay strings so leading zeros survive, and a cell with commas, quotes or line breaks is quoted.
The converter's preset "Google feed to ChatGPT feed (OpenAI)" renames id to item_id, link to url and image_link to image_url, writes pre_order where Google writes preorder, and adds the columns seller_name (empty, for you to fill), target_countries and store_country (both set to the US). It writes every value as text. In a CSV or TSV file that is what OpenAI's rules describe. In a JSON lines file, list fields such as target_countries still have to become real arrays, so CSV or TSV is the shorter way.
Which fields ChatGPT's feed needs is covered in the guide to the ChatGPT Shopping product feed; the comparison of Google's, Microsoft's and ChatGPT's feeds shows where the three differ. The ChatGPT Shopping feed checker checks the finished file.
Where Central helps#
Converting a file changes its shape, not its content: a GTIN that was missing in the XML is still missing in the CSV. Central researches the product data a listing needs from your own data, the open web and verified databases, backs every value with sources you can check and holds back what the sources do not support. It then writes titles, descriptions and attributes within each channel's limits.
Questions
How do I convert an XML product feed to CSV?
Load the XML file into a converter that understands repeated product elements, check that every product became one row, and save the table as CSV. Central's free product file converter does this in the browser: nested fields become dotted columns and repeated values are joined with a vertical bar.
Can Google Merchant Center read a CSV file?
Google's product file page lists tab-delimited .txt and .tsv files and .xml files, up to 4 GB. It does not list a .csv extension, so save a table as tab-delimited text before you add it to Merchant Center.
What does the g: in a Google XML feed mean?
It is a namespace prefix. The feed declares it once with xmlns:g="http://base.google.com/ns/1.0", and every Google attribute such as g:price or g:gtin carries it. Google says attributes without the prefix are ignored.
Why are accents and umlauts broken after converting?
The file was read or saved in the wrong character encoding. Save product files as UTF-8; Google names encodings other than UTF-8 and UTF-16 as a common cause of processing errors.
Is JSON lines the same as JSON?
No. A JSON file is usually one array that holds all records. A JSON lines file has no surrounding array: OpenAI's feed schema asks for each complete record on one line of the JSONL file.
Sources
- Create a product file for Merchant CenterGoogle Merchant Center Helpchecked 23 November 2026
- RSS 2.0 specificationGoogle Merchant Center Helpchecked 23 November 2026
- Atom 1.0 specificationGoogle Merchant Center Helpchecked 23 November 2026
- Create a tab-delimited product data sourceGoogle Merchant Center Helpchecked 23 November 2026
- Troubleshoot my data sourceGoogle Merchant Center Helpchecked 23 November 2026
- Additional image link [additional_image_link]Google Merchant Center Helpchecked 23 November 2026
- Price [price]Google Merchant Center Helpchecked 23 November 2026
- Extensible Markup Language (XML) 1.0 (Fifth Edition)W3Cchecked 23 November 2026
- Namespaces in XML 1.0 (Third Edition)W3Cchecked 23 November 2026
- RFC 4180: Common Format and MIME Type for Comma-Separated Values (CSV) FilesRFC Editorchecked 23 November 2026
- RFC 8259: The JavaScript Object Notation (JSON) Data Interchange FormatRFC Editorchecked 23 November 2026
- Product feed schemaOpenAI developer docschecked 23 November 2026
- Import or export text (.txt or .csv) filesMicrosoft Supportchecked 23 November 2026
- Keeping leading zeros and large numbersMicrosoft Supportchecked 23 November 2026
- Duplicate product descriptions: when they hurt and how to fix themGuides
- item_group_idGlossary
- PIM software compared: Akeneo, Salsify, Pimcore, Inriver, Plytix and moreComparisons
- Product data enrichment: what it adds, where it comes from, how to check itGuides
- Product data onboarding: from supplier files to a clean catalogGuides
- Product data sources: manufacturers, data pools, standards and public databasesGuides
- Product variants: how to structure colors, sizes and optionsGuides
- Supplier product data template: the fields to ask every supplier forGuides
- Units of measurement in product data: one unit, one formatGuides