Wrap Python in
TypeScript Safety

Seamlessly integrate the unmatched computational power of Python's elite ecosystem—like PyTorch, SciPy, pandas, and NumPy—directly within your TypeScript applications, fully protected by a robust type system.

Copy this into your coding agent to get started in one shot:

View full documentation
🔒

Full Type Safety

TypeScript definitions generated directly from Python source analysis via AST — no manual type writing.

🌐

Multi-Runtime

One API across Node.js, Bun, Deno (subprocess), and browsers (Pyodide WebAssembly).

Rich Data Types

First-class support for numpy, pandas, scipy, torch, and sklearn with Apache Arrow binary transport.

🛠

Zero-Config CLI

Run npx tywrap generate and get production-ready TypeScript wrappers with a single command.

Skip to content

Quick Start

bash
npm install tywrap
pip install tywrap-ir  # Python component for code generation
npx tywrap init
npx tywrap generate

tywrap and tywrap-ir are versioned independently. Install the latest published release of each package unless you need to pin them explicitly.

typescript
import { NodeBridge } from 'tywrap/node';
import { setRuntimeBridge } from 'tywrap/runtime';
import * as math from './generated/math.generated.js';

setRuntimeBridge(new NodeBridge({ pythonPath: 'python3' }));
const result = await math.sqrt(16); // 4 — fully typed

Development Hot Reload

typescript
import { startNodeWatchSession } from 'tywrap/dev';
import { NodeBridge } from 'tywrap/node';

const session = await startNodeWatchSession({
  configFile: './tywrap.config.ts',
  createBridge: async config =>
    new NodeBridge({
      pythonPath: config.runtime.node?.pythonPath ?? 'python3',
      timeoutMs: config.runtime.node?.timeout ?? 30000,
    }),
});

Use reloadNow() for an explicit rebuild or close() to stop watching. Node gets full hot reload, Pyodide gets manual bridge replacement through createBridgeReloader(...), and HTTP reload remains external to tywrap.

⚠️ Experimental — APIs may change before v1.0.0. See Releases for breaking changes.

If tywrap saves you time, a ⭐ on GitHub helps others find it.

Released under the MIT License.