npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@eleven-am/faker

v0.0.2

Published

A modern, strongly-typed fake data generator for TypeScript with a declarative, fluent API.

Readme

faker

A modern, strongly-typed fake data generator for TypeScript with a declarative, fluent API.

npm version License: MIT TypeScript

Features

  • 🔒 Strongly Typed: Full TypeScript support with type inference.
  • ⚡ Deterministic: Reproducible data generation with seed support.
  • 🧩 Composable: Build complex schemas from simple building blocks.
  • 🌐 Internationalization: Multi-locale support for names, addresses, and more.
  • 🔄 Fluent API: Chain methods for concise, readable schema definitions.
  • 📚 Comprehensive: Generate everything from simple values to complex objects.
  • 🔌 Zero Dependencies: Lightweight and self-contained.

Installation

npm install @eleven-am/faker
# or
yarn add @eleven-am/faker
# or
pnpm add @eleven-am/faker

Quick Start

import { f } from '@eleven-am/faker';

// Define a user schema
const userSchema = f.object({
  id: f.uuid(),
  username: f.string().minLength(5).maxLength(15),
  email: f.email(),
  isActive: f.boolean({ likelihood: 0.8 }),
  registeredAt: f.date().min('2020-01-01'),
  profile: f.object({
    name: f.name(),
    avatar: f.avatar(),
    bio: f.paragraph({ maxSentences: 3 })
  })
});

// Generate a single user
const user = userSchema.generate();
console.log(user);

// Generate multiple users with a specific seed
const users = userSchema.generateMany(10, { seed: 12345 });

Schema Types

Basic Types

// Strings
f.string({ minLength: 5, maxLength: 10, prefix: 'user-' })
f.string().minLength(5).maxLength(10).prefix('user-') // Fluent alternative

// Numbers
f.number({ min: 1, max: 100, precision: 2 })
f.number().min(1).max(100).precision(2) // Fluent alternative

// Booleans
f.boolean({ likelihood: 0.7 })
f.boolean().likelihood(0.7) // Fluent alternative

// Dates
f.date({ min: '2020-01-01', max: '2022-12-31' })
f.date().min('2020-01-01').max('2022-12-31') // Fluent alternative

// Enums
f.enum(['admin', 'user', 'editor'] as const)

// Literals
f.literal('constant value')

Advanced Types

// Objects
f.object({
  id: f.uuid(),
  name: f.string(),
  createdAt: f.date()
})

// Arrays
f.array(f.string(), { minLength: 3, maxLength: 7 })
f.array(f.number()).minLength(3).maxLength(7) // Fluent alternative

// Tuples (fixed length arrays with mixed types)
f.tuple(f.string(), f.number(), f.boolean())

// Records (dictionaries with dynamic keys)
f.record(f.string(), f.number())

// Unions (randomly choose one schema)
f.union(f.string(), f.number())

// Optional values
f.string().optional(0.3) // 30% chance of being null

// Dependent values (conditional generation)
f.dependent<Parent>(schema, {
  condition: (parent) => parent.includeDetail === true
})

Real-World Types

// Names
f.name({ gender: 'female' })

// Emails
f.email({ domain: 'example.com' })

// URLs
f.url({ includeQueryParams: true })

// Paragraphs
f.paragraph({ sentences: 3 })

// Addresses
f.address({ includeCountry: true })

// Phone numbers
f.phone({ countryCode: true })

// Avatars
f.avatar({ service: 'dicebear', style: 'avataaars' })

// Credit cards
f.creditCard({ type: 'visa' })

Advanced Usage

Type Inference

Use the Infer helper to extract the generated type from a schema:

import { f, Infer } from '@eleven-am/faker';

const userSchema = f.object({
  id: f.uuid(),
  name: f.string()
});

// TypeScript automatically infers the correct type
type User = Infer<typeof userSchema>;
// Equivalent to: { id: string; name: string; }

// Use the inferred type
function processUser(user: User) {
  // ...
}

processUser(userSchema.generate());

Deterministic Generation

Generate consistent data sets with seeds:

// Same seed produces the same output every time
const user1 = userSchema.generate({ seed: 12345 });
const user2 = userSchema.generate({ seed: 12345 });
console.log(user1.id === user2.id); // true

// For arrays
const users = userSchema.generateMany(10, { seed: 12345 });

Constraints and Transformations

Apply constraints and transformations to schemas:

// Ensure generated values meet a condition
const adultSchema = f.number({ min: 1, max: 100 })
  .where(age => age >= 18);

// Transform generated values
const emailSchema = f.string()
  .transform((str, ctx) => `${str}@example.com`);

// Chain transformations
import { transformers } from '@eleven-am/faker';

const titleSchema = f.string()
  .pipe(
    transformers.trim(),
    transformers.capitalize()
  );

Internationalization

Generate locale-specific data:

// French names
const frenchName = f.locale('fr-FR', f.name());

// UK addresses
const ukAddress = f.locale('en-GB', f.address());

API Reference

See the full API documentation for detailed information on all schema types, options, and methods.

License

MIT