HTML Table to CSV: Fix Broken Formatting in 5 Steps
By the LightCube Data team ยท Updated 2026-11-27
Fixing html table to csv broken formatting usually comes down to three things: the wrong delimiter, headers that spill into the first data row, or characters that were not encoded correctly. The fastest path is to extract the table with a tool that preserves the original row and column structure, then clean the export before it reaches your spreadsheet.
TL;DR: - Broken HTML table exports usually come from wrong delimiters, merged cells, or hidden characters. - Extract the table first, then clean separators, headers, and encoding before exporting. - Check the result in a plain text editor and a spreadsheet before you rely on it.
What causes broken formatting when you convert an HTML table to CSV?
Most broken exports are not caused by the CSV itself. They come from the source page and from the settings used during extraction.
Common culprits include:
- Wrong delimiter. The page may separate values with tabs, semicolons, or pipes, but the export writes commas.
- Merged or spanning cells. A header that covers three columns leaves empty cells underneath it.
- Hidden characters. Non-breaking spaces and invisible line breaks survive the copy and shift values into the wrong columns.
- Nested markup. Labels with bold text, links, or line breaks inside a cell can carry extra characters into the export.
- Encoding problems. Special characters such as currency symbols or accented letters may appear as question marks or garbled text.
- Numbers stored as text. Long identifiers, leading zeros, and values like product codes lose their formatting when a spreadsheet guesses the type.
Once you know which of these is happening, the fix becomes much faster than rebuilding the table by hand.
How do you fix an HTML table to CSV with broken formatting?
Here is a practical order of operations. It works whether the table came from a copy and paste, a browser extension, or a web extraction tool.
- Open the page and locate the table. Scroll to the table you need and confirm it is fully loaded, including any rows that load when you scroll.
- Extract the table instead of copying the text. Select the table with a dedicated extractor so rows and columns stay aligned. A browser extension such as LightCube Data is built for this step.
- Check the delimiter. If values appear crammed into one column, the separator is wrong. Switch from comma to tab, semicolon, or pipe and preview the result.
- Clean the header row. Remove blank cells, repeated labels, and any header text that was merged across several columns.
- Strip hidden characters. Replace non-breaking spaces with normal spaces and remove stray line breaks inside cells.
- Set the encoding. Choose UTF-8 when the table contains accents, symbols, or characters outside plain ASCII.
- Export and verify. Save as CSV, then open it in a text editor first to confirm the structure, and second in your spreadsheet to confirm the types.
Which delimiter should you use for a clean CSV export?
The comma is the most common choice, but it is not always the right one. The delimiter must match how the source table separates its values.
| Situation | Recommended delimiter | Why |
|---|---|---|
| Standard comma-separated data | Comma , |
Works with most spreadsheet defaults |
| European locale spreadsheet | Semicolon ; |
Avoids conflicts with decimal commas |
| Data copied from a plain text page | Tab \t |
Often survives copy and paste cleanly |
| Data pulled from a database view | Pipe \| |
Rarely appears inside the values |
| Values that contain commas | Comma with quoting | The export wraps those cells in quotes |
A quick test: paste a single row into a plain text editor. If you see one long line with no visible breaks, the delimiter is not being applied. If you see values separated by a consistent symbol, that symbol is your delimiter.
How do you clean up headers and merged cells before exporting?
Headers are where most "broken" tables become obvious. A row that reads Region | Q1 | Q2 | Q3 with an empty cell under Region is not a parsing failure. It is a layout choice on the page.
To clean it up:
- Fill empty header cells with the label from the merged cell above, or shorten the header to a single meaningful name.
- Remove duplicate headers such as
Value,Value,Valueand rename themValue 1,Value 2,Value 3. - Delete rows that are navigation labels, filter bars, or "showing 1 to 25 of 300" text.
- Strip footnote markers and inline icons that were captured as text.
- Keep one header row only. If the page repeats headers on scroll, keep the first occurrence.
If you need to reshape the table rather than just clean it, do that after extraction. A clean CSV with consistent columns is easier to pivot, filter, or import into a database than a messy one.
Why do numbers, dates, and symbols break after the export?
Even a perfectly structured CSV can look wrong once a spreadsheet opens it. That is usually a type detection issue, not a data issue.
- Leading zeros disappear. A product code like
00417becomes417. Import the column as text to keep it. - Long numbers lose precision. Very large identifiers can round when a spreadsheet treats them as numbers. Store them as text.
- Dates shift format. A value like
03/04/2024is ambiguous across regions. Export dates in ISO format,2024-03-04, where possible. - Currency symbols land in the wrong column. A symbol separated by a non-breaking space can be read as part of the next cell.
- Accents turn into odd characters. This points to an encoding mismatch. Save and reopen with UTF-8.
A simple habit prevents most of these: after importing, select the columns that should stay as text and set their type explicitly.
Should you export to CSV, Excel, or Google Sheets?
Each format has a sensible use, and the choice affects how much cleanup you need later.
| Format | Best for | Watch out for |
|---|---|---|
| CSV | Sharing, scripting, database imports | One table per file, no formatting |
| Excel (.xlsx) | Analysis, formulas, multiple sheets | Type guessing on import |
| Google Sheets | Collaboration and live sharing | Import settings for delimiters and types |
If the goal is a quick analysis, export to CSV and open it in your spreadsheet app. If you need formulas, charts, or several cleaned tables in one file, export to Excel. If colleagues need to work on the data together, import the CSV into Google Sheets and share the sheet.
You can also do the whole job in the browser with a web tool such as LightCube Data, which lets you extract a table, preview it, and send it to your spreadsheet without installing anything.
How can you check that the export is actually clean?
Verify in two places, in this order.
First, open the file in a plain text editor. A clean CSV looks like this:
Region,Revenue,Change
North,18400,12%
South,9200,-4%
Each row should have the same number of separators, and values containing a comma should be wrapped in quotes. If a row has fewer or more fields than the header, the extraction still has issues.
Second, open the same file in your spreadsheet and check three things: the column count, the data types, and any special characters. If the text view looks right but the spreadsheet looks wrong, the problem is in the import settings, not the export.
FAQ
Why does my HTML table to CSV export put everything in one column?
Your export is likely using a different delimiter than the source table. Try switching between comma, semicolon, tab, and pipe in the extraction settings and preview the result each time.
Can I fix a broken CSV without re-exporting the table?
Yes, in most cases. Open the file in a text editor or spreadsheet, set the correct delimiter on import, then clean headers, hidden characters, and column types manually.
How do I keep leading zeros and long product codes intact?
Import or format that column as text before the spreadsheet converts it to a number. This also prevents very long identifiers from losing precision.
Why do accented letters and currency symbols look garbled?
The file was probably saved with a different character encoding. Re-export or re-save using UTF-8, and make sure the spreadsheet is also set to read UTF-8.
Does a browser extension or web tool handle tables with merged cells?
Partly. Most tools read the visible grid, so merged headers leave blank cells that you fill in or rename yourself. Always preview the result before you rely on it.
Export any web table to CSV or Excel
Paste a page link into the LightCube web exporter and download its tables as CSV or Excel. Free for 25 rows; Pro is $9 once.
Try the web exporter ↗Based on a video by NA: How to Convert Excel to CSV (Quick and Correct). Written in our own words with added steps and an FAQ.
More guides
- Best Browser Extension for Copying Web Tables to CSV
- Best Chrome Extension for Table to Google Sheets
- Best Extension for Table to Excel Without Coding
- Best Free Tool to Copy Table from Website to Excel
- Best Free Web Table Exporter for Students (2024 Guide)
- Best HTML Table Scraper for Marketers (2024 Guide)