Overview
Introduction
Randomizing the order of rows in a dataset is useful for creating unbiased samples, shuffling a list of entries for a giveaway, or testing that a system doesn't depend on input order. This tool shuffles data rows while keeping the header pinned in place.
It uses a cryptographically strong random source, so the resulting order isn't statistically biased.
What Is CSV Row Shuffler?
A data-row shuffler for CSV: it randomly reorders every row below the header, which always stays fixed at the top of the output.
Randomness comes from a Fisher-Yates shuffle driven by crypto.getRandomValues(), matching the approach this repo's other random-category tools use for unbiased shuffles.
How CSV Row Shuffler Works
The CSV is parsed and the header row is split off from the data rows. The data rows array is shuffled in place with Fisher-Yates, drawing each swap index from crypto.getRandomValues() with rejection sampling.
The unchanged header is then reattached at the top of the shuffled data rows and the result is re-serialized to CSV.
When To Use CSV Row Shuffler
Use it to randomize the order of entries for a raffle, a randomized review order, or an unbiased sample selection.
It's also useful for testing that a downstream system's output doesn't depend on input row order.
Often used alongside CSV Column Shuffler and CSV Value Shuffler.
Features
Advantages
- Uses a cryptographically strong random source rather than Math.random for an unbiased shuffle.
- Keeps every row's own cell values completely intact: only row position changes.
- Always preserves the header row's fixed position at the top.
Limitations
- Requires at least two data rows to produce a meaningful shuffle.
- There's no way to seed or reproduce a specific shuffle order; every run is fresh randomness.
Examples
Best Practices & Notes
Best Practices
- Use this when you need a fair, unbiased random order of existing rows, e.g. for a drawing or randomized assignment.
- Combine with CSV Slicer afterward if you want to take a random sample of a fixed size after shuffling.
- Re-run the tool for a fresh random order; there's no seed to reproduce a prior shuffle.
Developer Notes
The shuffle draws its random integers from the random category's existing secureRandomInt helper (crypto.getRandomValues with rejection sampling) rather than Math.random, matching how this repo's other randomness-driven tools source entropy.
CSV Row Shuffler Use Cases
- Randomizing entries for a fair drawing or giveaway from a CSV list of participants
- Creating a randomized ordering of test cases or survey rows for unbiased review
- Testing that a system's behavior doesn't depend on the order data rows arrive in
Common Mistakes
- Expecting the header row to also be included in the shuffle; it's always kept fixed at the top.
- Using this when you actually need to scramble individual values rather than whole rows: that's CSV Value Shuffler's job.
Tips
- Pair with CSV Slicer to grab a fixed-size random sample after shuffling.
- Run it again if you want to compare a few different random row orders.