skillfed

pydantic-to-typescript2

Convert pydantic v1 and pydantic v2 models to typescript interfaces

pydantic-to-typescript2 v1.0.6 90.7K downloads/30d#13,567 on PyPI
Permissive license MIT DORMANT released

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-typescript2

uv

uv add pydantic-to-typescript2

poetry

poetry add pydantic-to-typescript2

Installing 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

Development Status :: 5 - Production/StableLicense :: OSI Approved :: MIT LicenseProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9

Tags

pydantic to typescript conversionpython typescript type generationpydantic models typescript interfacescross-language type definitionsapi schema typescript exportpydantic cli typescriptpython javascript type sync
type-generationpolyglotapi-contracts

More Software Development packages