pydantic-to-typescript2
Convert pydantic v1 and pydantic v2 models to typescript interfaces
What it is and what it does
pydantic-to-typescript2 is a command-line tool that reads Pydantic model definitions from Python modules and generates corresponding TypeScript interface definitions. It bridges the gap between Python and JavaScript/TypeScript codebases by allowing you to define your data schemas once in Pydantic and automatically export them as TypeScript types, eliminating the need to manually maintain duplicate type definitions across languages.
The tool scans Python modules for Pydantic models, converts them to JSON Schema, and then uses the json2ts utility to generate TypeScript interfaces. It can be invoked via CLI with module and output file paths, or programmatically. It supports excluding specific models and customizing the json2ts command invocation.
Use it for:
- Synchronize API request/response types between a Python backend and a TypeScript frontend without manual duplication.
- Generate TypeScript types for a Python service's data models to ensure frontend code matches backend contracts.
- Automate type definition generation in a monorepo where Python and JavaScript services share domain models.
- Export Pydantic validation schemas as TypeScript interfaces for client-side type checking and IDE autocomplete.
- Maintain a single source of truth for data structures across polyglot microservices.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Converts Pydantic models to TypeScript interfaces via a CLI tool, enabling shared type definitions between Python and JavaScript applications.
Yes, if you maintain both Python and TypeScript codebases that share data models. The low install friction and permissive license make it practical for eliminating type definition drift. However, maintenance is dormant—verify compatibility with your specific Pydantic and TypeScript versions before adopting, and plan for potential maintenance gaps if ecosystem changes occur.
Install
pydantic-to-typescript2 on PyPI
pip
pip install pydantic-to-typescript2uv
uv add pydantic-to-typescript2poetry
poetry add pydantic-to-typescript2Installing pydantic-to-typescript2
Before you install
Low install friction with a single runtime dependency on pydantic. Maintenance is dormant (701 days since last release), though the package is marked Production/Stable and supports Python 3.8 through 3.12.
License in practice
MIT license is permissive, allowing use in commercial and private projects with minimal restrictions.
Quickstart
pip install pydantic-to-typescript2
# CLI usage:
pydantic2ts --module backend.api --output ./frontend/apiTypes.ts
# Or programmatic usage via the package's generate function
Requires the json2ts CLI utility (json-schema-to-typescript npm package) to be installed and accessible on the system PATH.
Verify before relying
- Whether dormant maintenance status affects compatibility with recent Pydantic releases or TypeScript ecosystem changes.
- Actual test coverage and reliability for complex nested Pydantic models or advanced field configurations.
- Performance characteristics when converting large codebases with many models.
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — pydantic |
| Maintenance | dormant — 701 days since the last release |
| First released | |
| Downloads | 90,689/month — #13,567 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pydantic_to_typescript2-1.0.6-py3-none-any.whl
Keywords: pydantic, pydantic2, typescript, annotations, validation, interface
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
pydantic-to-typescriptConverts pydantic model definitions into…
permissive · top 5,000 on PyPI
sparkdanticConverts Pydantic models to PySpark schemas…
unclear · top 5,000 on PyPI
fastuiFastUI lets you build responsive web…
permissive · top 15,000 on PyPI
pydantic-compatProvides compatibility mixins and adapters to…
permissive · top 15,000 on PyPI
pydantic-numpyIntegrates NumPy arrays into Pydantic models…
permissive · top 15,000 on PyPI
pydantic-factoriesGenerates mock data objects that conform to…
permissive · top 15,000 on PyPI
pydantic-to-pyarrowConverts pydantic model definitions to pyarrow…
permissive · top 15,000 on PyPI
pydantic_yamlPydantic-YAML adds YAML serialization and…
permissive · top 5,000 on PyPI
flask-pydantic-specAdds OpenAPI documentation generation and…
unclear · top 15,000 on PyPI
jsiijsii is a Python runtime client that enables…
permissive · top 5,000 on PyPI