npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

unplugin-zod-to-mini

v0.1.6

Published

Transform Zod schemas to Zod/mini at build time

Readme

unplugin-zod-to-mini

NPM version Tests stability

A build-time transformer that converts Zod schemas to use zod/mini — a tree-shakable variant of Zod.

Why zod/mini?

Zod Mini is a tree-shakable variant of Zod. It implements the exact same functionality, but with a functional API instead of method chaining.

Bundle Size

Full Zod adds significant bundle weight to your application. zod/mini provides the same runtime validation with a fraction of the size. Based on the simple example z.boolean().parse(true):

| Package | Bundle size (gzip) | | -------- | ------------------ | | Zod Mini | 2.12kb | | Zod | 5.91kb |

For a more complex schema with objects (z.object({ a: z.string(), b: z.number(), c: z.boolean() })), the sizes are 4.0kb vs 13.1kb respectively.

This plugin automatically rewrites your Zod imports and transforms your schemas at build time, so you get the smaller bundle without changing your code.

API Differences

In regular Zod, you use method chaining:

const mySchema = z.string().optional().nullable();

In Zod Mini, you use functions instead:

const mySchema = z.nullable(z.optional(z.string()));

For validation methods:

// regular Zod
z.string().min(5).max(10).trim();

// Zod Mini
z.string().check(z.minLength(5), z.maxLength(10), z.trim());

When to Use This Plugin

Use this plugin if you want to:

  • Reduce bundle size — Convert existing Zod schemas to Zod Mini without rewriting code
  • Reduce memory usage — Particularly beneficial for backend services with many endpoints
  • Maintain DX — Keep using the familiar Zod method-chaining API while getting Zod Mini benefits

Skip this plugin if you:

  • Already use Zod Mini directly
  • Prefer the functional Zod Mini API
  • Don't have bundle size or memory constraints

Real-world Impact

In our testing with a ~250 endpoint Fastify service using input & output schema validations, converting from regular Zod to Zod Mini reduced memory consumption by ~20MB from cold boot.

Features

  • Automatic transformation from zod to zod/mini import
  • Supports most Zod methods: string, number, boolean, object, array, enum, literal, optional, nullable, etc.
  • Transforms validation methods: min, max, email, minLength, maxLength, uuid, url, etc.
  • Supports transform, refine, pipe, brand, extend, omit, pick
  • Object mode transformations: strictObject, looseObject, partial, required
  • Works with TypeScript and JSX

Install

npm install unplugin-zod-to-mini

Usage

Vite

// vite.config.ts
import zodToMini from "unplugin-zod-to-mini/vite";
import { defineConfig } from "vite";

export default defineConfig({
  plugins: [zodToMini()],
});

Rollup

// rollup.config.js
import zodToMini from "unplugin-zod-to-mini/rollup";

export default {
  plugins: [zodToMini()],
};

Webpack

// webpack.config.js
module.exports = {
  plugins: [require("unplugin-zod-to-mini/webpack")()],
};

Nuxt

// nuxt.config.ts
export default defineNuxtConfig({
  modules: ["unplugin-zod-to-mini/nuxt"],
});

esbuild

// esbuild.config.js
import { build } from "esbuild";
import zodToMini from "unplugin-zod-to-mini/esbuild";

build({
  plugins: [zodToMini()],
});

Rspack

// rspack.config.js
import zodToMini from "unplugin-zod-to-mini/rspack";

export default {
  plugins: [
    zodToMini({
      // options
    }),
  ],
};

Example

Before transformation:

import { z } from "zod";

const UserSchema = z.object({
  name: z.string().min(2).max(50),
  email: z.email(),
  age: z.number().min(0).optional(),
});

export type User = z.infer<typeof UserSchema>;

After transformation (build output):

import { z } from "zod/mini";

const UserSchema = z.object({
  name: z.string().check(z.minLength(2), z.maxLength(50)),
  email: z.email(),
  age: z.optional(z.number().check(z.gte(0))),
});

export type User = z.infer<typeof UserSchema>;

Options

interface PluginOptions {
  // Enable source maps for debugging
  sourceMaps?: boolean; // default: true
  // Enable JSX support
  jsx?: boolean; // default: false
}

Limitations

  • Some advanced Zod features may not be transformable — check the error message for unsupported methods and report them here :]

Credits

  • zod/mini — the lightweight Zod alternative
  • unplugin — the unified plugin system