Skip to content

duetds/sample-data-generator

Repository files navigation

Sample Data Generator

A TypeScript utility for generating realistic Finnish sample data for prototyping and testing.

Installation

Install directly from GitHub:

# Latest from main branch
npm install github:duetds/sample-data-generator

# Specific version tag (recommended)
npm install github:duetds/sample-data-generator#v1.0.0

Usage

// ESM
import { Generate } from "sample-data-generator"

// CJS
const { Generate } = require("sample-data-generator")

All methods accept an optional seed string to make output deterministic — the same seed always produces the same result.


First Name

Generates a random Finnish first name, weighted by population frequency.

Generate.firstName({
  seed: "ABC123" // Optional
})
// → "Matti"

Last Name

Generates a random Finnish last name, weighted by population frequency.

Generate.lastName({
  seed: "ABC123" // Optional
})
// → "Korhonen"

Email

Generates an email address from the given prefix.

Generate.email({
  prefix: "John Doe", // Required — used as the local part of the email
  suffix: "example",  // Optional — used as the domain name
  seed:   "ABC123"    // Optional
})
// → "john.doe@example.test"

Phone number

Generates a phone number with a weighted country code prefix.

Generate.phone({
  seed: "ABC123" // Optional
})
// → "+358001234567"

Date of Birth

Generates a date of birth between 18–80 years old by default.

Generate.dob({
  underage: false,   // Optional — if true, generates age 0–17 instead
  seed:     "ABC123" // Optional
})
// → "1990-01-01"

Finnish Personal Identity Code (SSN)

Generates a Finnish Personal Identity Code (henkilötunnus). Fake by default — individual number is in the 900–999 range to avoid collisions with real SSNs.

Generate.ssn({
  dob:      "1990-01-01", // Optional — date of birth in YYYY-MM-DD format
  underage: false,        // Optional — generate for a person under 18
  sex:      "male",       // Optional — "male" | "female" | "random"
  fake:     true,         // Optional — false generates a real-range individual number (100–899)
  seed:     "ABC123"      // Optional
})
// → "010190-923A"

Address

Generates a Finnish address.

Generate.address({
  seed: "ABC123" // Optional
})
// → {
//     streetAddress : "Mannerheimintie 1",
//     postalCode    : "00100",
//     area          : "Helsinki-Uusimaa",
//     municipality  : "Helsinki",
//     country       : "Finland"
//   }

Person

Generates a complete person profile.

Generate.person({
  seed: "ABC123" // Optional
})
// → {
//     firstName : "Matti",
//     lastName  : "Korhonen",
//     dob       : "1990-01-01",
//     ssn       : "010190-923A",
//     email     : "matti.korhonen@example.test",
//     phone     : "+358401234567",
//     address   : {
//       streetAddress : "Mannerheimintie 1",
//       postalCode    : "00100",
//       area          : "Helsinki-Uusimaa",
//       municipality  : "Helsinki",
//       country       : "Finland"
//     }
//   }

Company Name

Generates a random Finnish company name.

Generate.companyName({
  seed: "ABC123" // Optional
})
// → "Nordic Solutions Oy"

Business ID

Generates a Finnish Business ID (Y-tunnus). Always starts with 8 to indicate it is a test ID.

Generate.businessID({
  seed: "ABC123" // Optional
})
// → "8234567-3"

Company

Generates a complete company profile with a representative and employees.

Generate.company({
  seed:        "ABC123",        // Optional
  employees:   10,              // Optional — defaults to 1–9 if not specified
  emailFormat: "representative" // Optional — "standard" | "representative"
})
// → {
//     name           : "Nordic Solutions Oy",
//     businessID     : "8234567-3",
//     email          : "first.last@solutions.test",
//     phone          : "+358023423423",
//     address        : { ... },
//     representative : { ... },
//     employees      : [ ... ]
//   }

emailFormat controls the company email address:

  • "standard" — generic prefix such as info@, contact@, tuki@ (default)
  • "representative" — uses the representative's name, e.g. matti.korhonen@

Notes

  • All generated data is for testing and prototyping purposes only.
  • Data does not represent real individuals or companies.
  • Fake SSNs use individual numbers in the 900–999 range and will not pass real SSN validation.
  • Business IDs starting with 8 are not valid real Finnish business IDs.

About

Library for generating realistic Finnish sample data for prototypes

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors