Skip to content
Multi-process test data files generator
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Multi-process test data files generator.

This is handy when you want to generate large test data files (e.g. XMLs, JSONs, CSVs, etc), over multiple processes, utilising available CPU cores on your machine.


npm install -g datagen 


Create example header, segment, and footer template files:

datagen config

Generate 8 data files containing 1 million segments in each file, written to data0 ... data7 output files, running over 8 processes:

datagen gen -s 1000000 -w 8 -o data


DataGen uses three template files: header, segment, and footer. These templates are simple text files which are used to construct a data file in this format:

segment 0
segment 1
segment N (number of segments - 1)

Templates can contain the following parameters:

{gen_id}Unique to each datagen execution. Default value is master process PID, can be overridden via -i flag.
{worker_id}Unique to each worker. Value from 0 to number of workers - 1.
{segment_id}Unique to each segment within the generated data file, repeated in each file. Value from 0 to number of segments - 1. Not available in header and footer templates.
{integer()}Random integer.
{integer(100, 200)}Random integer between 100 and 200.
{float()}random float.
{float(1.23, 5.67)}Random float between 1.23 and 5.67 .
{date()}random date between 1970 and 2020 in ISO format.
{date('yyyy-mm-dd')Random date between 1970 and 2020 in yyyy-mm-dd format.
Check out felixge/node-dateformat for more date formats.
{date(2000, 2010)}Random date between 2000 and 2010 in ISO format.
{date('yyyy-mm-dd', 2000, 2010)}Random date between 2000 and 2010 in yyyy-mm-dd format.
{select('apple', 'orange', ..., 'kiwi')}Select one item from the arguments. You can have as many arguments as you want.
{word()}Random word from Lorem Ipsum.
{word(3)}Random 3 words from Lorem Ipsum.
{first_name()}Random first name.
{last_name()}Random last name.
Something went wrong with that request. Please try again.