python2ts + pythonlib
Two packages that bridge the Python and TypeScript worlds. Transpile Python to clean TypeScript, or use Python's best APIs directly in your TypeScript projects.
Two Packages, One Mission
The Transpiler — Converts Python source code to clean, idiomatic TypeScript. Full type preservation, docstring conversion, and intelligent runtime imports.
$ npm install python2ts
The Runtime Library — 20+ Python standard library modules reimplemented in TypeScript. Zero dependencies, tree-shakeable, works standalone.
$ npm install pythonlib
Why python2ts?
AI-First Workflow
Python dominates AI/ML. TypeScript powers modern web apps. Bridge the gap.
Full Type Safety
Python type hints become TypeScript types automatically. Generics, Protocols, TypedDicts.
Battle-Tested
2000+ tests. Runs on every commit across Node.js, Bun, Deno, and browsers.
Zero Dependencies
pythonlib has zero runtime dependencies. No bloat, no supply chain risks.
Runtime Support
Tested on every commit across all major JavaScript runtimes
pythonlib Modules
Use Python's best APIs in TypeScript — standalone, without the transpiler
itertools
combinations, permutations, product, chain, cycle, groupby
functools
lruCache, partial, reduce, pipe, compose, cache
collections
Counter, defaultdict, deque, OrderedDict
datetime
datetime, date, time, timedelta
pathlib
Path with exists, readText, writeText, glob
hashlib
md5, sha1, sha256, sha512, blake2b
re
search, match, findAll, sub, compile
+ 12 more
math, json, string, os, sys, time, glob, shutil...
Ready to get started?
Install python2ts and start transpiling Python to TypeScript in minutes.