You have to import it like:
import * as faker from 'faker';
And use it like:
faker.name.findName()
Answer from Saravana on Stack OverflowFakerJS
fakerjs.dev › guide › usage
Usage | Faker
Faker mostly generates values for primitives. This is because in the real world, most object schemas simply look very different. So, if you want to create an object, you most likely need to write a factory function for it. For our example, we use TypeScript to strongly type our model.
Top answer 1 of 2
56
You have to import it like:
import * as faker from 'faker';
And use it like:
faker.name.findName()
2 of 2
7
The documentation now says:
import { faker } from '@faker-js/faker'
If it is to be localized data, the desired locale can also be attached.
import { faker } from '@faker-js/faker/locale/de'
Feat: Add typescript types for @faker-js/faker
Generate massive amounts of fake data in the browser and node.js - Feat: Add typescript types for @faker-js/faker · Issue #9 · faker-js/faker More on github.com
Is there a library that generates fake data from a typescript interface?
Fakerjs or chance come to mind More on reddit.com
Videos
01:29
How to Use faker.js with TypeScript: A Complete Guide for Developers ...
09:08
Mastering Playwright | Faker for Test Data Generation | QA Automation ...
01:05:11
Component-driven development with Faker.js - YouTube
04:07
Create Test Data Using Faker - YouTube
15:14
Building test-data-bot in TypeScript: Part 3 - YouTube
09:35
Create Fake Data in TypeORM using Faker.js | TypeScript Tutorial ...
npm
npmjs.com › package › @faker-js › faker
@faker-js/faker - npm
3 weeks ago - // ESM import { faker } from '@faker-js/faker'; // CJS const { faker } = require('@faker-js/faker'); export function createRandomUser() { return { userId: faker.string.uuid(), username: faker.internet.username(), email: faker.internet.email(), avatar: faker.image.avatar(), password: faker.internet.password(), birthdate: faker.date.birthdate(), registeredAt: faker.date.past(), }; } export const users = faker.helpers.multiple(createRandomUser, { count: 5, });
» npm install @faker-js/faker
Published Mar 23, 2026
Version 10.4.0
npm
npmjs.com › package › @types › faker
@types/faker - npm
October 23, 2024 - Stub TypeScript definitions entry for faker, which provides its own types definitions. Latest version: 6.6.11, last published: a year ago. Start using @types/faker in your project by running `npm i @types/faker`. There are 301 other projects in the npm registry using @types/faker.
» npm install @types/faker
Published Oct 23, 2024
Version 6.6.11
DEV Community
dev.to › serifcolakel › building-a-typescript-helper-for-mock-data-generation-with-zod-and-faker-4b8f
Building a TypeScript Helper for Mock Data Generation with Zod and Faker - DEV Community
November 5, 2024 - import { ZodSchema, ZodObject, ZodString, ZodNumber, ZodBoolean, ZodArray, ZodOptional, ZodNullable, ZodTypeAny, ZodStringCheck, } from "zod"; import { faker } from "@faker-js/faker"; import { z } from "zod"; const handleStringCheck = (check: ZodStringCheck) => { switch (check.kind) { case "date": return faker.date.recent().toISOString(); case "url": return faker.internet.url(); case "email": return faker.internet.email(); case "uuid": case "cuid": case "nanoid": case "cuid2": case "ulid": return crypto.randomUUID(); case "emoji": return faker.internet.emoji(); default: return faker.lorem.word
GitHub
github.com › magiqans › faker.ts
GitHub - magiqans/faker.ts: Faker typescript decorators
Generate massive amounts of fake contextual data using typescript decorators · import Faker, { address, internet } from "faker-ts"; @Faker() class MyObject { @address.name() randomName: string; @internet.email() randomEmail: string; } const instance = new MyObject(); instance.randomName; // // Rowan Nikolaus instance.randomEmail; // Kassandra.Haley@erich.biz
Starred by 3 users
Forked by 2 users
Languages TypeScript 100.0% | TypeScript 100.0%
GitHub
github.com › faker-js › faker › issues › 9
Feat: Add typescript types for @faker-js/faker · Issue #9 · faker-js/faker
January 7, 2022 - Generate massive amounts of fake data in the browser and node.js - Feat: Add typescript types for @faker-js/faker · Issue #9 · faker-js/faker
Author damienwebdev
DEV Community
dev.to › sirwanafifi › ts-faker-generating-fake-data-using-typescript-interfaces-2em2
ts-faker - Generating fake data using TypeScript interfaces - DEV Community
July 29, 2021 - You just need to define your schema as TypeScript interfaces, and the test data will be generated automatically. I thought it would be a good idea to share the source code with you so that you can learn something from it. I hope you enjoy it. source: https://github.com/SirwanAfifi/ts-faker website: https://ts-faker.vercel.app/
Untitled Publication
noam.hashnode.dev › using-faker-in-typescript
Using faker in typescript - noam honig's blog
January 9, 2022 - import { Remult } from "remult"; import { AccountManager } from "../AccountManagers/AccountManager.entity"; import { name, internet } from 'faker'; export async function generateDataIfEmpty(remult: Remult) { console.log("here"); const repo = remult.repo(AccountManager); if (await repo.count() == 0) { for (let index = 0; index < 10; index++) { const firstName = name.firstName(); const lastName = name.lastName(); await repo.save({ firstName, lastName, email: internet.email(firstName, lastName) }, true) } } }
FakerJS
fakerjs.dev › guide
Getting Started | Faker
Faker was originally written in Perl and this is the JavaScript port.
GitHub
github.com › cytle › faker-ts
GitHub - cytle/faker-ts: Mock data from TypeScript
import { tsMock, tsMockService } from 'faker-ts'; const files = ['foo.ts']; // foo.ts // export interface IFoo { a: string } const mocker = tsMock(files); mocker.generateMock('IFoo'); // { "a": "commodo voluptate pariatur" } // or listening file change const mocker = tsMockService(files); // see more Mock Server with Koa ... import Koa from 'koa'; import Router from 'koa-router'; import * as ts from 'typescript'; import { tsMockService } from 'faker-ts'; export function createServer(files: string[], jsonCompilerOptions?: ts.CompilerOptions, basePath?: string) { const app = new Koa(); const rou
Starred by 32 users
Forked by 7 users
Languages TypeScript 93.0% | JavaScript 7.0% | TypeScript 93.0% | JavaScript 7.0%
Vercel
ts-faker.vercel.app
Generate Fake Data
Generate Fake Data
GitHub
github.com › google › intermock
GitHub - google/intermock: Mocking library to create mock objects with fake data for TypeScript interfaces · GitHub
Starred by 1.2K users
Forked by 70 users
Languages TypeScript 92.4% | JavaScript 7.6%
CodeSandbox
codesandbox.io › examples › package › @types › faker
@types/faker examples - CodeSandbox
AboutStub TypeScript definitions entry for faker, which provides its own types definitions740,493Weekly Downloads
GitHub
github.com › faker-js › faker
GitHub - faker-js/faker: Generate massive amounts of fake data in the browser and node.js · GitHub
// ESM import { faker } from '@faker-js/faker'; // CJS const { faker } = require('@faker-js/faker'); export function createRandomUser() { return { userId: faker.string.uuid(), username: faker.internet.username(), email: faker.internet.email(), avatar: faker.image.avatar(), password: faker.internet.password(), birthdate: faker.date.birthdate(), registeredAt: faker.date.past(), }; } export const users = faker.helpers.multiple(createRandomUser, { count: 5, });
Starred by 15K users
Forked by 1.1K users
Languages TypeScript 99.6% | JavaScript 0.4%
Reddit
reddit.com › r/node › is there a library that generates fake data from a typescript interface?
r/node on Reddit: Is there a library that generates fake data from a typescript interface?
November 10, 2025 -
Is there a library that generates fake data from a typescript interface? Sometimes, I need to generate some fake data to use as a mock, and I was wondering if there was an easy way to do so instead of doing it manually, which takes too much time. I don't want to use a LLM for this.
Top answer 1 of 11
20
Fakerjs or chance come to mind
2 of 11
8
It’s often easier to generate typescript types/interfaces from real data than the other way around since types aren’t available at runtime. If you happen to be using zod, this package can help you. https://www.npmjs.com/package/zod-schema-faker