Fake CSV data for testing imports, reports and spreadsheets
Sooner or later every system that accepts CSV needs a test file. An import screen has to be tried with ten rows and with ten thousand. A report has to be checked with plenty of names, dates across a whole year and a sensible spread of numbers. A spreadsheet template needs data to show the client before the real data exists. Using a copy of production data for this is the habit that ends up in a breach notice, because test files get emailed, committed and forgotten. Fake data has none of that risk.
This generator builds the file from a schema you write in plain text, one column per line. Each line names the column and says what goes in it: id for a running number, fullName for a person, email for a matching address, int(18, 90) for a whole number in a range, float(0, 5, 2) for a decimal with two places, pick(free, pro, team) for one of a fixed set of values, and date or datetime for a point in time. The header row is made from the names, in the order you wrote them. A mistake in a line is reported with its line number, so you never get half a file.
The values are drawn with crypto.getRandomValues, the browser’s cryptographic random source, and spread evenly across each range with both ends included. Emails are built from the same row’s name, so Priya Okafor gets an address like priya.okafor@example.org, and they only ever use example.com, example.org and example.net. Those three domains are reserved for documentation and testing, so a system under test that sends a welcome email by mistake cannot reach anyone.
The output is real CSV, not text with commas pasted in. A value that contains the separator, a quote mark or a line break is wrapped in quotes with inner quote marks doubled, and rows end with CRLF as RFC 4180 and Excel expect. You can choose comma, semicolon, tab or pipe as the separator, and the download is named mock.csv, mock.tsv or mock.txt to match. Up to 10,000 rows can be made at a time.
The schema format is shared with the Mock JSON Generator, so the same description can produce a CSV for one test and a JSON array for another. Names come from short international lists, so they repeat in large files; that is fine for load and layout testing but not for anything that studies names. Nothing is sent anywhere. The rows are made on your device, and a new set is one press of Regenerate away.