Skip to content
ZeroServer.tools

HTML Table Sorter

Paste an HTML table, sort its rows by any column — numerically or alphabetically — and export the result.

How the HTML Table Sorter works

Paste any HTML snippet that contains a <table> element — copied straight from a webpage, a report, or hand-written markup. Click Parse Table and the tool reads the header row (from <thead> or the first row of <th> cells) and every data row, then renders an interactive preview. Click any column header to sort the rows by that column — click it again to flip between ascending and descending order.

Sorting auto-detects whether a column holds numbers (including values formatted like $1,200.50 or 92%) or text, so numeric columns sort by magnitude instead of alphabetically — but you can force Numeric or Alphabeticalmode from the dropdown if auto-detection guesses wrong. Alphabetical sorting is locale-aware and case-insensitive, and treats embedded numbers naturally (so "Item 2" sorts before "Item 10").

Once sorted, copy the regenerated <table> markup or download it as a standalone .htmlfile — and because the pasted table and the sort (column, direction, mode) are stored in the page URL, you can share a link that opens the exact same sorted table. Cells are compared and emitted as plain text, so formatting inside a <td> (links, <strong>, spans) is not preserved in the output. All parsing and sorting happens entirely in your browser using the native DOMParser — your table data is never uploaded anywhere.

Built and maintained by Meet Shah · Last updated

What this tool is used for

  • Sorting a pasted table by a column without opening a spreadsheet.
  • Finding the largest or smallest value in a scraped table quickly.
  • Reordering a table before pasting it into a document.
  • Checking whether a column is numeric by seeing how it sorts.
  • Sorting a table whose own page offers no sorting.

Frequently Asked Questions

How should a sortable column be marked up?
With `aria-sort` on the header — `ascending`, `descending` or `none` — and a real `<button>` inside the `<th>` to trigger it. The button is what makes it operable by keyboard, and `aria-sort` is what announces the current state.
Why does my numeric column sort wrongly?
Because text sorting compares character by character, so 10 precedes 2. A numeric column needs a comparator that parses the value, and a mixed column needs a natural sort — which is what makes `file10` follow `file2` rather than precede it.
How should dates be sorted?
By an underlying value, not by the displayed text. A `data-sort-value` attribute holding an ISO date lets the display stay localised while the comparison stays correct — otherwise "15 August" and "3 September" sort alphabetically into the wrong order.
Does sorting need to be stable?
For multi-column sorting, yes. Stability means equal elements keep their relative order, so sorting by name and then by department produces a meaningful two-level ordering. JavaScript's sort has been required to be stable since ES2019.
Should a large table be sorted client-side?
Up to a few thousand rows, comfortably. Beyond that the table should not all be in the DOM anyway — server-side sorting with pagination is both faster and more accessible than a page holding fifty thousand rows the user cannot navigate.

Common errors and gotchas

  • Sorting a numeric column as text, where 10 sorts before 9.
  • Losing merged cells, which cannot survive a row reorder meaningfully.
  • Sorting a table whose row order carried meaning, such as a sequence or a ranking.
  • Including a totals row in the sort, which then lands in the middle.
  • Assuming a currency or a date column sorts correctly without being parsed as such.

Related Formatters & Validators tools

Private & free — this tool runs entirely in your browser.

IndieKitShip your Next.js startup in days.affiliate