Getting Started
Keep it simple: install, run one command, see a file.
Prerequisite
Section titled “Prerequisite”- Node.js 18+ (needed for both Node and Python wrappers)
Install
Section titled “Install”npm install schemabridgepnpm add schemabridgeyarn add schemabridgebun add schemabridgePython users: pip install schemabridge also works, but it still needs Node 18+ on your machine.
First conversion (one schema)
Section titled “First conversion (one schema)”- Create a Zod schema (
schema.ts):
import { z } from 'zod';
export const userSchema = z.object({ id: z.string().uuid(), email: z.string().email(), createdAt: z.date(),});- Convert to Pydantic:
npx schemabridge convert zod schema.ts --export userSchema --to pydantic --out user.pyYou’ll get user.py with a UserSchema class.
Convert a whole folder
Section titled “Convert a whole folder”schemabridge convert folder ./src/schemas --out ./generated --to pydantic --init- Mirrors your folder structure by default.
- Adds
__init__.pyso you canfrom generated.user import UserSchema. - Use
--flatto dump everything in one folder.
- Use Zod v4 helpers directly:
z.date(),z.string().uuid(),z.string().email(). Avoidz.string().datetime()(deprecated). - For TypeScript path aliases, run from the project root so
tsconfig.jsonis picked up. - If a TS file won’t load, ensure
tsxis installed during dev, or compile TS to JS first.