csvkit.org
CSV (Comma-Separated Values) utilities, in the browser
Say hi →

Shuffle or Reverse CSV Rows

uniform shuffle · optional seed · reverse · header stays put

Randomise the row order of a CSV — for splitting a dataset into train and test sets, removing the ordering bias in a manual review queue, or randomising an assignment list. Or just reverse it, when a log arrived oldest-first and you want newest-first. The header row never moves.

order
Or drop a .csv file here, or
ready

How to shuffle a CSV

  1. Paste the CSV or drop a file.
  2. Leave the mode on shuffle, or switch to reverse for a straight flip.
  3. Add a seed if you need the same order again later.
  4. Copy or download.

A real shuffle, not a random sort

The rows are permuted with a Fisher–Yates shuffle, where every ordering is equally likely. The tempting one-liner — rows.sort(() => Math.random() - 0.5) — is not uniform: comparison sorts call the comparator a limited number of times and rely on it being consistent, so a random comparator leaves rows biased toward their starting positions. If you've ever wondered why a "shuffled" list kept its first few items near the front, that's why.

Split into train and test

Shuffle with a seed, then take the first 80% with Slice rows (first N) and the rest with all but the first N. Because the seed fixes the order, both halves are reproducible and provably disjoint — worth doing before any evaluation you'll need to defend later.

FAQ

Does the header get shuffled into the data?

No. The header is parsed separately and always written back on top.

Can I get the original order back?

Only if you can identify it — add a row number with Add column before shuffling, then sort on it to restore the order.

Does the same seed always give the same order?

Yes, for the same input file. Change the file's rows and the ordering changes too, since the shuffle runs over whatever rows are present.

Is anything uploaded?

No — it runs in your browser.

Privacy

100% client-side. No upload. See the privacy policy.