pydantic-to-typescript
Convert pydantic models to typescript interfaces
What it is and what it does
pydantic-to-typescript is a CLI tool that reads pydantic model definitions from a Python module and generates corresponding TypeScript interface definitions. It bridges the gap between Python and JavaScript type systems by allowing teams to maintain a single authoritative source of type definitions in Python, then automatically generate matching TypeScript interfaces for frontend consumption. The tool depends on pydantic for model introspection and json2ts for the actual TypeScript generation.
The package is designed for full-stack applications where Python backends serve APIs consumed by TypeScript/JavaScript frontends. Instead of manually keeping type definitions in sync across languages, you define your data models once in pydantic and run the tool to generate TypeScript interfaces that match exactly. The generated interfaces are marked as auto-generated to discourage manual edits, reinforcing the single-source-of-truth pattern.
Use it for:
- Generate TypeScript types for a backend's request/response models to keep frontend and backend type definitions synchronized.
- Exclude sensitive or internal pydantic models from TypeScript output using the --exclude flag when only a subset of models should be exposed.
- Integrate into a build pipeline to regenerate TypeScript definitions whenever pydantic models change, ensuring frontend types never drift from backend reality.
- Convert a Python module with multiple interdependent pydantic models into a single TypeScript definitions file for import across a frontend codebase.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Converts pydantic model definitions into TypeScript interface definitions via a CLI tool, enabling a single source of truth for type definitions across Python and JavaScript applications.
Yes, if you have a Python backend with pydantic models and a TypeScript frontend that needs to stay in sync. The package solves a real problem—type definition drift—with minimal overhead. Install friction is low and the MIT license is unrestricted. The main caveat is dormant maintenance (last release 630 days ago), so if you rely on cutting-edge pydantic features or need active support, evaluate whether the tool handles your specific model patterns before committing.
Install
pydantic-to-typescript on PyPI
pip
pip install pydantic-to-typescriptuv
uv add pydantic-to-typescriptpoetry
poetry add pydantic-to-typescriptInstalling pydantic-to-typescript
Before you install
Low friction install with a single runtime dependency (pydantic). Maintenance is dormant—last commit was 2024-11-22 and no release in 630 days—but the package is marked Production/Stable and carries 432 GitHub stars, suggesting it remains functional for its narrow use case.
License in practice
MIT license (permissive) places no restrictions on use, modification, or distribution in commercial or proprietary projects.
Quickstart
pip install pydantic-to-typescript
from pydantic import BaseModel
class User(BaseModel):
name: str
age: int
# Then run: pydantic2ts --module mymodule --output ./types.ts
Requires json2ts CLI utility (npm package json-schema-to-typescript) to be installed and accessible on the system PATH or specified via --json2ts-cmd flag.
Verify before relying
- Whether the package handles complex pydantic features (validators, computed fields, discriminated unions) correctly in TypeScript output.
- Performance characteristics when converting large numbers of models or deeply nested model hierarchies.
- Compatibility with recent pydantic v2 field definitions and serialization modes beyond basic type mapping.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — pydantic |
| Maintenance | dormant — 630 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 863,682/month — #4,867 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pydantic_to_typescript-2.0.0-py3-none-any.whl
Keywords: annotations, interface, pydantic, typescript, validation
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-typescript2Converts Pydantic models to TypeScript…
permissive · top 15,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
jsonschema-pydantic-converterConverts JSON Schema definitions to Pydantic v2…
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-numpyIntegrates NumPy arrays into Pydantic models…
permissive · top 15,000 on PyPI
flask-pydantic-specAdds OpenAPI documentation generation and…
unclear · top 15,000 on PyPI
pylint-pydanticA Pylint plugin that extends Pylint's…
copyleft · top 5,000 on PyPI
pydantic-handlebarsRenders Handlebars templates for composing LLM…
permissive · top 5,000 on PyPI