Skip to content
Logo

Installation

fabricator ships as ESM only, with zero runtime dependencies.

Requirements

  • An ESM-capable runtime — Bun, Node, Deno, or a bundler that supports ES modules
  • TypeScript — while not strictly required, it is highly recommended (fabricator is TypeScript-first; the value types you get back from .fabricate() are inferred from your schema, not hand-annotated)

Optional: a dynamic data library

By default, fabricator generates fuzzing values, not realistic-looking ones — T.string.whereby({ length: { max: 20 } }) gives you a random string, not a name. When you want output that reads like real data, add the faker extension:

bun add @ghostry/fabricator-extension-faker-v10 @faker-js/faker
import { en } from "@faker-js/faker";
import { initialize, registry } from "@ghostry/fabricator";
import { fakerExtension } from "@ghostry/fabricator-extension-faker-v10";
 
const { T } = initialize({
  types: registry.extend(fakerExtension({ locale: en })),
});
 
const schema = T.faker.person.fullName();
// T.string using faker values when fabricated

Faker's generators draw from fabricator's own seed there, so those fields replay like every other one. See faker for the full surface.

You can also reach any data library by hand through .as(...) or T.opaque — see T.opaque, including what it takes to keep such fields reproducible.