Skip to content

A CLI tool to generate fake data in CSV, JSON, and XML formats with automatic type inference and optional headers.

Notifications You must be signed in to change notification settings

ozlemkorpe/cli-fake-test-data-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CLI Fake Data Generator 🛠️

A lightweight CLI tool for generating fake test data in CSV, JSON, and XML formats.
Built with Node.js and TypeScript.

Generate realistic test data in seconds with customizable headers, automatic data type inference, and multiple export formats.


Features ✨

  • Generate fake data from an example line
  • Automatically infers data types: string, email, date, integer, url, UUID, char, boolean
  • Supports headers for CSV, JSON (object array), and XML
  • Export to multiple formats: CSV, JSON, XML
  • Custom output path support for exports
  • Clear terminal and show available commands
  • Interactive CLI with colored commands for easy usage

Installation 💻

npm install

Running the App 🚀

Running in Development Mode

Runs the CLI directly using ts-node (requires TypeScript installed):

npm run dev

Build and Start

Compile the TypeScript code to JavaScript in the dist/ folder and start the CLI:

npm start

You'll see a welcome message and available commands.

Notes
  • npm run build only compiles the TypeScript code without running the CLI.
  • The compiled files will be output to the dist/ folder.

Available Commands 📋

Command Description
Generate Starts the fake data generation flow. You will be asked for:
- An example data line
- Whether to add headers (optional)
- Number of rows to generate
Export <format> <filename> [--path <directory>] Exports the last generated data to a file. Supported formats: csv, json, xml.
Example: Export csv users --path ./output
Clear Clears the terminal output and shows available commands again
Help Displays this help screen with command usage details
Exit Exits the application

Example Usage 📝

Generate Data

> Generate
Please enter an example data line:
> John, 28.02.1996, john.doe@email.com, 1234, http://example.com
Would you like to add headers? (y/n)
> y
Enter headers separated by commas:
> name, birthdate, email, id, website
How many rows of data would you like to generate?
> 10

Export Data

> Export csv users --path ./exports
✔ CSV file created successfully: /exports/users.csv

> Export json users
✔ JSON file created successfully: /exports/users.json

> Export xml users
✔ XML file created successfully: /exports/users.xml

Clear Terminal

> Clear

Help

> Help

Example CLI Useage

image

Example File Output

image

Notes 📝

  • Data types are inferred automatically from your example line
  • Supported date formats: DD.MM.YYYY , DD/MM/YYYY
  • Header count must match the number of fields in the example data
  • If headers are provided:
    • CSV will include a header row
    • JSON will be exported as an array of objects
    • XML fields will include name attributes

Folder Structure 📂

├─ src/
│  ├─ cli/
│  │  ├─ clear.ts
│  │  ├─ commandsText.ts
│  │  ├─ help.ts
│  │  ├─ welcome.ts
│  ├─ core/
│  │  ├─ generateData.ts
│  │  └─ inferSchema.ts
│  ├─ exporters/
│  │  ├─ csvExporter.ts
│  │  ├─ jsonExporter.ts
│  │  └─ xmlExporter.ts
│  ├─ input/
│  │  └─ prompt.ts
│  ├─ store/
│  │  └─ dataStore.ts
│  ├─ types/
│  │  └─ schema.ts
│  │  └─ state.ts
│  ├─ utils/
│  │  └─ applyHeaders.ts
│  │  └─ fileUtils.ts
│  └─ app.ts
│  └─ index.ts

License 📜

MIT License

About

A CLI tool to generate fake data in CSV, JSON, and XML formats with automatic type inference and optional headers.

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors