Cross-language schema converter: Zod → Pydantic & TypeScript
SchemaBridge converts Zod schemas to Pydantic v2 models and TypeScript type definitions, so TS and Python services can share a single source of truth.
- Avoid hand-porting Pydantic models from Zod
- Skip JSON Schema detours and brittle codegen glue
- Keep one schema definition and generate everything else
# Node / TypeScript
npm install schemabridge
# Python (still needs Node 18+)
pip install schemabridgeRequirements
- Node.js >= 18.0.0
- Python >= 3.9 (only for the Python package)
// schema.ts
import { z } from 'zod';
export const userSchema = z.object({
id: z.string().uuid(),
email: z.string().email(),
createdAt: z.date(),
});schemabridge convert zod schema.ts \
--export userSchema \
--to pydantic \
--out user.pyGenerates a UserSchema Pydantic model in user.py.
schemabridge convert folder ./src/schemas \
--out ./generated \
--to pydantic \
--init- Scans
./src/schemasrecursively - Converts all exported Zod schemas
- Mirrors folder structure
- Adds populated
__init__.pyfiles (imports +__all__) so you canfrom generated import UserSchemaorfrom generated.user import UserSchema - Use
--flatto dump everything into a single directory
pip install schemabridge
schemabridge convert zod schema.ts \
--export userSchema \
--to pydantic \
--out user.pyThe Python CLI wraps the bundled Node CLI and supports the same commands and flags.
- ✅ Python + TypeScript from one schema – Zod in, Pydantic and
.d.tsout - ✅ Enum support built in – Enums work out of the box in both Python and TypeScript
- ✅ Folder conversion – Convert whole folders, not just single files
- ✅ Multiple schemas per file – Finds every exported schema for you
- ✅ Python package mode –
--initbuilds import‑friendly Python packages - ✅ Flexible output – Keep your folder structure or flatten everything into one folder
- Only exported schemas are converted; non‑exported helpers are ignored
- Circular schema dependencies are not supported
- TypeScript path aliases need to be discoverable from the working directory
Contributions are welcome! Here's how you can help:
- Report bugs - Open an issue with a minimal reproduction
- Request features - Share your ideas in discussions or issues
- Submit PRs - Fix bugs, improve docs, or add features
- Spread the word - Star the repo, share on social media
MIT (see LICENSE)