zod4-mock
Schema-driven mocks, done right for Zod 4
Type-safe mock data from your Zod v4 schemas — the only library with relational consistency across entities. Competitive with hand-coded faker; faster than @anatine/zod-mock on the CLI baseline (see /bench).
Cross-entity consistency, out of the box
Every highlighted ID resolves to a real entity in the same generated world. No manual wiring.
Review (generated) }
"id" : "81734cca-daea-4241-8c6a-8dd2c7f53b41"
"productId" : "5791ca88-c86e-432b-8d9a-d5a48f5c09da"
"userId" : "1b5eee2b-f451-4e3e-9909-cf97fd0cfff3"
"rating" : 4
"body" : "An element makes little for section."
"createdAt" : "2025-11-22T03:43:14.455Z"
1b5eee2b-f451-4e3e-9909-cf97fd0cfff3 → User "Sophia Smith"
5791ca88-c86e-432b-8d9a-d5a48f5c09da → Product "James Smith"
Feature comparison
| Feature | zod4-mock | zod-mock | faker |
|---|---|---|---|
| Zod v4 schemas | ✓ | ✗ | — |
| Relational / cross-entity IDs | ✓ | ✗ | ✗ |
| Type-safe output | ✓ | ✓ | ✗ |
| Seeded / deterministic | ✓ | ✗ | ✓ |
| No schema required | ✗ | ✗ | ✓ |
| Handles discriminated unions | ✓ | ~ | — |
warm path ~3× vs zod-mock on flat schemas (CLI baseline)
entity types 7 in the relational e-commerce showcase
schema coverage Zod 4 full coverage — no feature gaps