๐ CSV Fundamentals ยท 7 min read
Why Is My CSV File Larger Than XLSX? The Compression Gap
A CSV file can hold exactly the same rows as the workbook next to it and still take up more room on disk. The reason is not that CSV wastes space. It is that the two formats are doing different jobs: one is a compressed archive, the other is text.
This article answers the size question with numbers we measured today, then covers the part people usually miss, which is that a compressed CSV is frequently smaller than the XLSX you compared it against.
Quick answer
An XLSX is a ZIP archive of XML parts, so it is compressed every time it is saved. A CSV is uncompressed plain text. Comparing them directly is comparing an archive against raw text, which is why an XLSX often comes out smaller even though it carries far more information. Compress the CSV and the ordering usually flips: in our test the CSV was 1.63 times the size of the XLSX, and 0.35 times its size after gzip.
What is actually inside an XLSX file
An .xlsx file is not a spreadsheet in the way a .csv is a spreadsheet. It is a container. Rename a copy from .xlsx to .zip and you can open it with any archive tool, which is how the format is designed to work. Microsoft's own explanation of the format says it plainly:
The Open XML Format uses zip compression technology to store documents, offering potential cost savings as it reduces the disk space required to store files and decreases the bandwidth needed to send files via e-mail, over networks, and across the Internet.
Inside the archive sit separate XML files for the sheet data, the styles, the shared strings and the theme. We opened a workbook we had just written from a 50,000-row dataset and listed the parts, comparing the uncompressed size of each part with the size it occupies inside the file:
| Part inside the XLSX | Uncompressed | Stored in the file |
|---|---|---|
| xl/worksheets/sheet1.xml | 16,216,002 bytes | 1,764,185 bytes |
| xl/theme/theme1.xml | 10,140 bytes | 1,552 bytes |
| xl/styles.xml | 2,550 bytes | 593 bytes |
| xl/workbook.xml | 545 bytes | 305 bytes |
The sheet data starts out as a 16.2 MB XML document and lands on disk as 1.76 MB, roughly 11% of its original size. Those are hard numbers from one file rather than a general rule, but the mechanism is the same in every workbook: repetitive XML compresses hard, and the file you see is the compressed result.
What we measured: CSV against XLSX
We wrote two datasets with the csvmodule in Python's standard library and with openpyxl 3.1.5, then compared the files on disk. Both writers received the same rows in the same order.
| Dataset | CSV (UTF-8) | CSV + gzip -6 | XLSX |
|---|---|---|---|
| 50,000 rows ร 6 columns (id, account, name, date, amount, status) | 2,883,657 bytes | 613,416 bytes | 1,768,698 bytes |
| 20,000 rows ร 2 columns (id, long repeated log line) | 5,348,927 bytes | not measured | 323,252 bytes |
Two things stand out. First, the plain CSV is 1.63 times the XLSX in the first dataset and 16.55 times the XLSX in the second, so yes, a CSV can tower over the workbook it came from. Second, the gzipped CSV is smaller than the XLSX in both spirit and number: 613,416 bytes against 1,768,698 bytes, or 0.35 times the workbook.
That second result is the useful one. If your problem is disk space or transfer time rather than a tool that refuses compressed files, compressing the CSV solves it without changing a single value in the file.
When the CSV is the smaller file
The surprise runs the other way too, and often. A workbook that has been used as a working document carries weight that has nothing to do with data: number formats on every column, conditional formatting rules, unused styles left behind by deleted rows, pivot caches, charts and embedded images. None of that belongs in a CSV, so exporting to CSV sheds all of it at once.
A practical way to see which situation you are in: open the workbook, press Ctrl+End to find the last cell in use, and compare that with the range you actually care about. If the used range is far larger than the data, the file is carrying history, and the CSV export will be the smaller file.
How to shrink a CSV that will not fit
- Compress it. Measured at 21.3% of the original in our test. This is reversible and changes no values, which makes it the only step on this list with no downside.
- Split it into parts with the CSV splitter, which keeps the header row on each part. Use this when the limit you hit is a row or row-per-sheet ceiling rather than a byte ceiling.
- Drop columns nobody reads. A single unused free-text column can be a third of the file. Check the column list with the CSV analyzer before you delete anything.
- Round the numbers you export. Full-precision decimals cost bytes in every row, and a report rarely needs fifteen digits of precision.
- Write dates in ISO format.
2026-09-23is ten characters and unambiguous;23/09/2026 00:00:00is nineteen and needs a convention agreed between you and the reader. - Check the line endings. RFC 4180 defines the record separator as CRLF. If your pipeline writes CRLF where LF would do, you are adding a byte to every row.
When file size actually matters
Size is only a problem at a boundary. The boundaries people hit are upload caps on reporting platforms, email attachment limits, version control repositories where a large text file is stored as text, and field transfers where the connection is slow. Outside those situations a large CSV is doing its job: it is the version of the data that any system, in any language, on any operating system, can read.
Worth knowing before you shrink anything: the operations that make a file smaller are not equally safe. Compression and splitting are reversible. Deleting rows or columns is not. If you are handing the file to someone else, say which of the two you did.
How to check both formats yourself
- Export the data to CSV and note the size of the file on disk.
- Save the workbook as .xlsx and note that size.
- Compress the CSV and note the size of the compressed copy.
- Compare all three numbers, then decide which limit you are actually up against, because the answer determines whether you should compress, split, or trim columns.
Frequently asked questions
Why is my CSV file larger than the XLSX file with the same data?
Because an XLSX file is compressed and a CSV file is not. An XLSX is a ZIP archive holding XML parts, and it is zipped again every time you save it. A CSV holds the same values as plain text with no compression step at all, so you are comparing raw text against an archive. Microsoft describes the format this way: the Open XML Format uses zip compression technology to store documents.
Is XLSX always smaller than CSV for the same rows?
No. For plain value data the comparison usually favours XLSX, because the XML inside it is repetitive and compresses well. Once a workbook carries number formats, conditional formatting, pivot caches, unused styles or embedded images, the CSV of the same numbers can be far smaller. In our test the CSV came out 1.63 times the XLSX for numeric data, and 16.55 times the XLSX for a two-column text export, so the direction depends on what is inside the workbook.
Does zipping a CSV make it smaller than the XLSX?
In our measurement, yes. Compressing the 2,883,657-byte CSV with gzip at level 6 produced a 613,416-byte file, which is 21.3% of the original CSV and 0.35 times the 1,768,698-byte XLSX holding the same rows. The reason is that a gzipped CSV contains no XML scaffolding, no styles and no theme, so there is simply less to store. Exact ratios vary with your data.
Can Excel open a gzipped CSV?
Excel does not open .gz files directly. Unzip the file first with a tool that understands gzip, or decompress it in a script, and then import the plain .csv. Some databases, ETL tools and command-line loaders accept .csv.gz as-is, so check what your importer expects before assuming you need to expand the file.
Why does the file size not scale with the number of rows?
Row count is only one factor. Size is also driven by how many characters each field holds, how much of the text repeats, how many decimals you keep, whether dates are written as 2026-09-23 or as 23/09/2026 14:00:00, whether fields are quoted, whether a byte order mark was written, and whether lines end with CRLF or LF. RFC 4180 defines the line break as CRLF, and switching a large file from LF to CRLF adds one byte per row.
Can I make the XLSX smaller instead?
An XLSX is already compressed, so the remaining wins come from removing things rather than from compression. Delete sheets you no longer use, clear unused styles and conditional formats, remove pivot caches and embedded images, and keep only the columns the report actually needs. Saving a copy with the formatting stripped often reduces the file more than any export setting.
Does a large CSV mean something is wrong with the export?
Usually not. A CSV export is deliberately plain: no compression, no types, no formatting. The size only becomes a problem when it meets a limit that happens to be smaller than your file, such as an upload cap on a reporting tool, an email attachment limit, or a platform that refuses files above a fixed size. If you are not hitting a limit, a large CSV is often the most portable version of the data you have.
What is the safest way to shrink a CSV that is too big?
Decide what the file is for before cutting anything. If it is for storage or transfer, compress it, because compression is reversible and changes no values. If it is for a tool with a hard row or column ceiling, split it into parts and keep the header on each part. Only drop columns or rows when you are sure nobody needs them, and record what you removed, because that step is the one that cannot be undone.
Tools mentioned in this guide
The measurements above are a short Python script and two file sizes. These three shorten the work when the file is large enough that you cannot open it by hand:
- OpenCode Go โ writing a file with the csv module, saving it as XLSX and printing three sizes is a few lines in a terminal, which is easier to repeat next month than rebuilding it in a spreadsheet. Try OpenCode Go
- Stack AI โ when an export lands on a schedule, a workflow can check the size and row count before the file reaches the reporting step, instead of letting a truncated import pass silently. Try Stack AI
- Softr โ if the same large file is re-sent every month, putting the records in a no-code app once means the file stops being the only place the data lives. Try Softr
Some links above are affiliate links โ if you buy through them we may earn a commission at no extra cost to you. OpenCode Go uses our referral link; the other two currently point to each vendor's official page until our tracking links are approved.
Too Big to Open the Usual Way?
Split the file by row count or size in the browser, keep the header on every part, and leave the original untouched.
File sizes in this article were measured on 2026-09-23 with the csv module from Python's standard library and openpyxl 3.1.5, writing both formats from the same rows. The description of the Open XML format is quoted from Microsoft's support page on Open XML file name extensions, retrieved the same day. The CRLF record separator is from RFC 4180, section 2.
Related reading
CSV Fundamentals โ other guides that pair well with this one.
Browse all guides in the NoCodeCSV blog.