Overview
Introduction
Sometimes you need to randomize the order columns appear in, for testing that a downstream system doesn't assume a fixed column order, or for creating varied sample data. This tool shuffles whole columns at once.
It uses a cryptographically strong random source so the shuffle isn't biased toward any particular ordering.
What Is CSV Column Shuffler?
A whole-column shuffler for CSV: it randomly reorders which position each column appears in, moving the header cell and every data cell in that column together as one unit.
Randomness comes from a Fisher-Yates shuffle seeded by crypto.getRandomValues(), the same rejection-sampling approach used elsewhere in this repo's random category.
How CSV Column Shuffler Works
The CSV is parsed and padded to a rectangle. A list of column indices is generated and shuffled in place with Fisher-Yates, drawing each swap index from crypto.getRandomValues() with rejection sampling to avoid modulo bias.
Every row (including the header) is then rebuilt by reading its cells in the new shuffled column order.
When To Use CSV Column Shuffler
Use it to generate test fixtures that verify a system doesn't secretly depend on column order.
It's also handy for creating visually varied sample data from a single source CSV.
Often used alongside CSV Row Shuffler and CSV Value Shuffler.
Features
Advantages
- Uses a cryptographically strong random source rather than Math.random for an unbiased shuffle.
- Keeps each column's own values fully intact: only column position changes.
- Works on the whole grid at once, header and data rows included, in a single pass.
Limitations
- Requires at least two columns 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 specifically to test column-order independence, not to anonymize or obscure which value belongs to which field: that's what CSV Value Shuffler is for.
- Combine with CSV Row Shuffler if you want both row and column order randomized independently.
- Re-run the tool if you want a different random ordering; there's no seed to control the outcome.
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 Column Shuffler Use Cases
- Testing that a CSV-consuming system correctly reads by header name rather than assuming column position
- Generating varied sample datasets from one source file for demos or testing
- Creating a shuffled-column decoy version of a file for a training exercise
Common Mistakes
- Expecting this to shuffle individual values: it only moves whole columns, so values within a column stay grouped together.
- Using this to anonymize data, when CSV Value Shuffler's per-cell scrambling is the tool actually suited for that.
Tips
- If you need only rows shuffled and not columns, use CSV Row Shuffler instead.
- Run the shuffle multiple times if you want to compare several different random column orders.