LightCube Data Extractor

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:

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.

  1. 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.
  2. 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.
  3. 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.
  4. Clean the header row. Remove blank cells, repeated labels, and any header text that was merged across several columns.
  5. Strip hidden characters. Replace non-breaking spaces with normal spaces and remove stray line breaks inside cells.
  6. Set the encoding. Choose UTF-8 when the table contains accents, symbols, or characters outside plain ASCII.
  7. 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:

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.

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