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:
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 fabricatedFaker's generators draw from fabricator's own seed parameters, so those fields replay like every other one. See the Faker guide 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.
Optional: schema adaptation for runtime validation
fabricator doesn't validate — nothing here checks a value against a schema. When you want the same shape to serve as a validator as well as a generator, add the TypeBox adapter:
import { toTypeBox } from "@ghostry/fabricator-adapter-typebox-v0";
const TProduct = toTypeBox(ProductSchema);It targets @sinclair/typebox (0.34.x) specifically — hence the -v0. See the TypeBox guide for the default-mapping table and how to override it per schema.
