{"library":"python2ts","title":"python2ts","description":"python2ts is an AST-based Python-to-TypeScript transpiler that converts Python code into clean, idiomatic TypeScript while preserving type annotations and semantics. The current stable version is 1.4.3 (January 2026), with active development and frequent releases (multiple per week). It supports a wide range of Python features including dataclasses, list/dict comprehensions, pattern matching, f-strings, async/await, decorators, context managers, generators, and standard library modules via the accompanying pythonlib runtime. Unlike other transpilers, python2ts produces readable, maintainable TypeScript output with full type preservation and has minimal runtime overhead, making it suitable for migrating large Python codebases to TypeScript. Requires Node >=22.0.0.","language":"javascript","status":"active","last_verified":"Fri May 01","install":{"commands":["npm install python2ts"],"cli":{"name":"python2ts","version":null}},"imports":["import python2ts from 'python2ts'","import { transpile } from 'python2ts'","import type { TranspileOptions } from 'python2ts/types'","import { cli } from 'python2ts'"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { transpile } from 'python2ts';\n\nconst pythonCode = `\ndef greet(name: str) -> str:\n    return f\"Hello, {name}!\"\n`;\n\ntry {\n  const result = transpile(pythonCode, {\n    filename: 'example.py',\n    runtime: 'pythonlib', // default runtime path\n  });\n  console.log(result.code);\n  // Output:\n  // import { greet } from \"pythonlib/builtins\"\n  // function greet(name: string): string {\n  //   return `Hello, ${name}!`;\n  // }\n} catch (error) {\n  console.error('Transpilation failed:', error.message);\n}","lang":"typescript","description":"Shows basic transpilation of a Python function with type hints and f-string to TypeScript.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}