Home / Content and Data / Data Table

Data Table in JavaScript, Free with Live Demo

Free data table in plain JavaScript. Click headers to sort, search every column, filter by department, choose page size, select rows and export the results to a CSV file.

Open live demoDownload HTML fileView code on GitHub
Data Table JavaScript project: a sortable, searchable table with filters, pages, row selection and CSV export

Runs on: Intl.Collator and Blob downloads. Works in all modern browsers.

What is the Data Table?

A table of 64 team members. Click any header to sort up or down, search across every column with matches highlighted, and filter by department.

Choose how many rows per page, move between pages, tick rows or a whole page and export either the selection or all filtered rows as a CSV file.

Good for

  • Admin panels and dashboards
  • Order and customer lists
  • Reports and exports
  • Internal directories

What this project does

How it works

  1. Filter, sort, sliceEvery change runs the same pipeline: filter by search and department, sort by the chosen column, then take one page.
  2. Sort like a humanIntl.Collator with numeric set compares names in the right language order and sorts Item 2 before Item 10.
  3. Export what you seeCSV is built from the filtered rows, or only the ticked ones, then downloaded through a Blob link. A BOM makes Excel read accents correctly.

The key JavaScript

This is the heart of the project. The full file has the rest, including the screen layout and error handling.

const collator = new Intl.Collator(undefined, { numeric: true, sensitivity: "base" });
const view = data
  .filter((r) => Object.values(r).join(" ").toLowerCase().includes(query))
  .sort((a, b) => collator.compare(a[key], b[key]) * dir)
  .slice((page - 1) * size, page * size);

const csv = [headers, ...rows.map((r) => keys.map((k) => r[k]))].map((r) => r.join(",")).join("\n");
link.href = URL.createObjectURL(new Blob(["\ufeff" + csv], { type: "text/csv" }));

How to use it

  1. Click Download HTML file above.
  2. Open the file in a code editor, like VS Code.
  3. Run it from a local server with npx serve . so the camera, microphone and AI features are allowed.
  4. Change the text and colors, then upload it to GitHub Pages, Netlify or your own site. It is one file with no build step.

Questions people ask

How many rows can it handle?

A few thousand rows sort and search instantly. For more, load pages from your server with the same sort and search values.

Why add a BOM to the CSV?

Excel needs it to read accented letters like ü correctly. Other apps ignore it.

Is the sticky header accessible?

Yes. The headers are real buttons inside th elements, and aria-sort tells screen readers the sort direction.

More Content and Data projects