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

@loydjs/zod-compat

v1.0.1

Published

Loyd zod-compat — Zod migration tools

Readme

CI License Bundle TypeScript npm downloads


Overview

@loydjs/zod-compat provides bidirectional conversion between Zod and Loyd schemas, plus an automated codemod that migrates your entire codebase in one command. If you have an existing Zod project and want Loyd's performance, this is your migration path.


Installation

npm install @loydjs/zod-compat

Requires @loydjs/core · @loydjs/schema · zod · Node.js ≥ 20 · TypeScript ≥ 5.4


API

fromZod(zodSchema)

Converts a Zod schema to a Loyd schema. Supports all common Zod types.

import { fromZod } from "@loydjs/zod-compat";
import { z } from "zod";

const ZodUser = z.object({
  name:  z.string().min(2).max(100),
  email: z.string().email(),
  age:   z.number().int().min(0).max(120),
  role:  z.enum(["admin", "user", "guest"]),
  tags:  z.array(z.string()),
  address: z.object({
    street: z.string(),
    city:   z.string(),
  }).optional(),
});

const LoydUser = fromZod(ZodUser);

// Use as a normal Loyd schema
const result = safeParse(LoydUser, req.body);

toZod(loydSchema)

Converts a Loyd schema back to a Zod schema. Useful when you need to use a Zod-specific API (e.g. tRPC, OpenAPI generators that only support Zod).

import { toZod } from "@loydjs/zod-compat";

const ZodUser = toZod(LoydUser);

// Use with tRPC, Zod-specific libraries, etc.
const router = t.router({
  createUser: t.procedure
    .input(ZodUser)
    .mutation(({ input }) => db.users.create(input)),
});

runCodemod(path, options)

Automated migration — scans your codebase and rewrites Zod imports and schema definitions to Loyd equivalents.

import { runCodemod } from "@loydjs/zod-compat";

await runCodemod("./src", {
  write:   true,    // write changes to disk (default: false = dry run)
  verbose: true,    // log each transformed file
});

// Output:
//  src/schemas/user.ts       (3 schemas migrated)
//  src/schemas/post.ts       (1 schema migrated)
//  src/api/validation.ts     (5 schemas migrated)
//  Migrated 47 files, 312 schemas

Or use the CLI directly:

npx loyd-codemod ./src --write
npx loyd-codemod ./src --write --verbose
npx loyd-codemod ./src --dry-run   # preview without writing

Schema conversion table

| Zod | Loyd | |:---|:---| | z.string() | string() | | z.string().min(n) | string().minLength(n) | | z.string().max(n) | string().maxLength(n) | | z.string().email() | string().email() | | z.string().uuid() | string().uuid() | | z.string().url() | string().url() | | z.number() | number() | | z.number().min(n) | number().min(n) | | z.number().max(n) | number().max(n) | | z.number().int() | number().int() | | z.boolean() | boolean() | | z.literal(v) | literal(v) | | z.object({}) | object({}) | | z.array(s) | array(s) | | z.union([...]) | union([...]) | | z.discriminatedUnion(k, [...]) | discriminatedUnion(k, [...]) | | z.optional(s) | optional(s) | | z.nullable(s) | nullable(s) | | z.enum([...]) | union([literal("a"), literal("b"), ...]) | | z.tuple([...]) | tuple([...]) | | z.record(s) | record(s) | | z.map(k, v) | map(k, v) | | z.set(s) | set(s) |


Dependencies

| Package | Role | |:---|:---| | @loydjs/core | LoydSchema base types | | @loydjs/schema | Target schema constructors |

Peer dependencies

| Package | Version | |:---|:---| | zod | ≥ 3.0.0 |


Documentation

loyddev-psi.vercel.app


License

MIT © b3nito404