Package Exports
- python2ts
Readme
python2ts
AST-based Python to TypeScript transpiler — Write Python, ship TypeScript.
Convert Python code to clean, idiomatic TypeScript with full type preservation.
Quick Start
npm install python2ts# Transpile a file
npx python2ts input.py -o output.ts
# Pipe from stdin
cat script.py | npx python2ts > script.tsExample
def fibonacci(n: int) -> list[int]:
a, b = 0, 1
result = []
for _ in range(n):
result.append(a)
a, b = b, a + b
return resultBecomes:
import { range } from "pythonlib"
function fibonacci(n: number): number[] {
let [a, b] = [0, 1]
let result: number[] = []
for (const _ of range(n)) {
result.push(a)
;[a, b] = [b, a + b]
}
return result
}Documentation
| Resource | Description |
|---|---|
| Homepage | Project overview, features, and quick start |
| Getting Started | Installation and first steps |
| Syntax Reference | Python → TypeScript transformation rules |
| Runtime Library | Using pythonlib for Python standard library |
| API Reference | Complete API documentation |
Runtime Support
Tested on every commit: Node.js (v22, v24) · Bun · Deno · Browsers
Related
License
MIT © Sebastian Software GmbH