Free tool
Sortable HTML table.
Paste a table, a whole page, or CSV — every table gets click-to-sort column headers that order money, percentages and dates by value, plus an optional filter box and sticky header. No jQuery, no DataTables: one small inline script. Try it on the preview, then copy it, download it, or share it as a link that stays sortable.
Publishes the page to Comma: one URL instead of an attachment, still sortable for everyone who opens it, and readers comment on the exact row instead of describing it in a chat thread. Free, no card.
How the sorting works
- The header row is the last row of
<thead>, or the first body row when it is made only of<th>cells — the shape most exports and hand-written tables use. - Values sort by type: numbers with currency symbols, thousands separators, percent signs or accounting parentheses by value; recognisable dates chronologically; the rest as text with natural number order.
- Sorting is stable and per
<tbody>, so grouped sections stay grouped and rows with equal values keep their original order. data-sort-valueon any cell overrides the text it sorts by.- Running the output back through the tool replaces the block instead of adding a second one.
When the table should be a link
A sortable table emailed as an attachment is a file half the recipients open in a preview pane that blocks scripts, so the headers do nothing. Published as a report it is one URL that opens in the browser with sorting intact, comments sit on the row they are about, and re-publishing keeps the previous version as a revision. If the numbers are refreshed on a schedule, a routine can post the new table to the same link.
Questions
- How do I make an HTML table sortable?
- Paste the table — or the whole page — into the editor on this page, or paste CSV and let it build the table. Every table gets clickable column headers: click once to sort ascending, again for descending. Copy the finished page, download it, or copy just the snippet and paste it before </body> in a page you already have.
- Does it need jQuery, DataTables or any library?
- No. The output is one small <style> and one <script> block — plain JavaScript with no dependencies and no network requests, around 4 KB. It works in a file opened from disk, in a CMS that allows script tags, and in a Comma report.
- Does it sort numbers, money and dates correctly?
- Yes. A cell that reads as a number — including $1,240,000, 92%, −5 or an accounting-style (1,200) — sorts by value, not alphabetically, so 9,900 comes before 38,200. ISO dates (2026-10-12), slashed dates (10/12/2026) and written-out dates (Oct 12, 2026) sort chronologically. Everything else sorts as text with natural number ordering, so “Item 2” comes before “Item 10”. Empty cells always go to the bottom.
- Can I control the value a cell sorts by?
- Yes. Add a data-sort-value attribute to a cell and that value is used instead of the visible text — useful for a status column that should sort by severity rather than alphabetically, or a cell that shows “3 days ago” but should sort by a timestamp.
- What does the filter box do?
- It adds a search field above each table that hides rows not containing what you type, matching any column, case-insensitively, with a live “n of m rows” count. Turn it off for a sort-only table.
- Will it change how my table looks?
- Barely. Your own CSS is kept as it is; the block adds a pointer cursor and a small sort arrow to header cells, and the filter box if enabled. Sticky header keeps the header row in view while a long table scrolls, and gives header cells a white background only if they had none.
- Which tables get skipped?
- Tables with no header row, tables with fewer than two body rows, and tables whose body uses rowspan or colspan — merged cells make “sort by column 3” ambiguous, so those are left exactly as they were rather than scrambled.
- Is it accessible?
- Headers are focusable and sort with Enter or Space, the current order is exposed through aria-sort for screen readers, and the filter field is labelled and announces its row count.
- Is my data uploaded?
- No. Everything happens in your browser, and the preview runs in a sandboxed iframe. The data only leaves your machine if you click “Get a shareable link” and publish it as a report — where the table stays sortable for everyone who opens the link.
Related: CSV to HTML table · Excel to HTML table · JSON to HTML table · HTML table to CSV · HTML viewer · all free tools