Playground

Define Mongoose schemas with Zod.

zod-mongoose provides a single source of truth for your data models with full TypeScript type safety. No more duplicate definitions.

example.ts
import { z } from 'zod/v4';
import { toMongooseSchema } from '@nullix/zod-mongoose';

const UserZodSchema = z.object({
  username: z.string().min(3),
  email: z.string().email(),
});

const UserSchema = toMongooseSchema(UserZodSchema);

Powerful features for developers

    Type Safety

    Enjoy full TypeScript support and prevent inconsistencies between your document interfaces and Mongoose schemas.

    Automatic Mapping

    Zod validators like .min(), .max(), and .regex() are directly converted to the appropriate Mongoose SchemaType options.

    Native Discriminators

    Support for z.discriminatedUnion is automatically translated into robust Mongoose discriminators for polymorphic data.

    Studio & Playground

    Test and visualize your schema transformations in real-time with the included Studio and online playground.

    Isomorphic

    Use the same schemas on both the frontend and the backend thanks to the built-in frontend mode.

    Nuxt 4 Ready

    Seamless integration with Nuxt 4 and Nitro for validating request bodies using Zod schemas.

Ready to enhance your Mongoose workflow?

Join developers who choose better type safety and less duplicate code.

:::