--- id: pydantic-to-typescript version: "2.0.0" license: MIT license_treatment: permissive maintenance: dormant --- # pydantic-to-typescript — Convert pydantic models to typescript interfaces License: permissive · Maintenance: dormant · Downloads: 863.7K/mo ## 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 above — 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 pip install pydantic-to-typescript uv add pydantic-to-typescript poetry add pydantic-to-typescript ## Installing 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_current - Install friction: low - Maintenance: dormant - Downloads: 863.7K/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags pydantic to typescript conversion, generate typescript from python models, python typescript type sync, pydantic typescript interface generator, cross-language type definitions, python javascript type bridge, type-generation, cross-language-sync, api-tooling [View on SkillFed](https://skillfed.io/packages/pydantic-to-typescript) · [View on PyPI](https://pypi.org/project/pydantic-to-typescript/)