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

Random Sample of CSV Rows

N rows or a percentage · optional seed for reproducibility · no duplicates

Pull a random subset of rows out of a CSV — a manageable test fixture, a QA sample for manual review, or a slice small enough to load into a spreadsheet. Every row is equally likely and no row is picked twice. Set a seed and the same file always gives you the same sample, which is what makes a sample citable in a ticket.

sample
Or drop a .csv file here, or
ready

How to sample a CSV

  1. Paste the CSV or drop a file.
  2. Choose a row count, or switch to percent and enter something like 5 for 5%.
  3. Type any word as a seed if you want the sample to be reproducible — qa-round-3 works fine.
  4. Copy or download. The header is always included.

Why the seed matters

Without a seed you get a fresh random sample on every run, which is fine for a quick look but impossible to talk about: nobody else can reproduce "the 200 rows I checked". With a seed, the selection is a pure function of the seed and the row count, so you can write "seed qa-round-3, 200 rows" in a ticket and anyone can regenerate exactly those rows from the same file. Change the seed to get a different, equally reproducible sample.

Sampling done properly

The selection is a partial Fisher–Yates shuffle over row indices, which is uniform and never returns the same row twice — unlike the common "pick a random row N times" approach, which produces duplicates and skews toward some rows. Keep original row order only affects presentation: the same rows are chosen either way, and leaving it on makes the sample easier to compare against the source file.

FAQ

Is the sample stratified by a column?

No — it's a simple random sample of all rows. For a per-group sample, filter to one group first and sample each group separately, then merge the results.

What if I ask for more rows than the file has?

You get every row, and the status line tells you the real count.

Can I get the rows that weren't sampled?

Not directly. Add a row number with Add column first, then the sampled numbers tell you exactly which rows were taken.

Is anything uploaded?

No. Sampling happens in your browser.

Privacy

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