skillfed

quickjs-rs

Sandboxed JavaScript execution for Python, via wasmtime + rquickjs.

quickjs-rs v0.2.5 305.6K downloads/30d#7,793 on PyPI11
Permissive license MIT Active released

What it is and what it does

quickjs-rs runs JavaScript inside a WebAssembly sandbox, isolating guest code from the Python host. The package bundles quickjs-ng (a QuickJS fork) compiled to WebAssembly and driven by wasmtime; it ships as a pure-Python wheel with no native compilation step. You write Python code that creates a Runtime and Context, then eval JavaScript strings or async code, optionally registering Python callables as JS globals and vice versa.

The sandbox supports ES modules with custom host-controlled resolution, TypeScript source stripping before evaluation, and full async/await semantics bridging Python and JS. You can also capture and restore entire VM snapshots—heap state, closures, pending promises—as binary payloads. The security model relies on WebAssembly's linear-memory isolation; the JS engine cannot access Python's address space, though wasmtime itself remains the residual attack surface.

Use it for:

  • Execute untrusted or user-supplied JavaScript safely without exposing the Python process to direct memory access.
  • Bridge Python and JavaScript logic in a single process—call Python functions from JS and vice versa with type conversion.
  • Load and run ES modules with custom resolution policy, enabling plugin architectures or dynamic code loading.
  • Strip and execute TypeScript source code without a separate compilation step or type-checking pipeline.
  • Snapshot a fully initialized JS VM state and restore it into fresh contexts for fast, stateful re-execution.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Executes JavaScript code inside a WebAssembly sandbox from Python, with support for ES modules, TypeScript stripping, async/await, and Python-to-JS function bridging.

Yes, if you need sandboxed JavaScript execution in Python and can tolerate the experimental status. The low install friction, active maintenance, permissive license, and zero known vulnerabilities make it a reasonable choice. Read the security guide before production use—wasmtime updates are critical, and snapshot bytes are treated as trusted input. Not suitable if you need a mature, battle-tested JS runtime or if your Python version is below 3.11.

Install

quickjs-rs on PyPI

pip

pip install quickjs-rs

uv

uv add quickjs-rs

poetry

poetry add quickjs-rs

Installing quickjs-rs

Before you install

Low friction: ships as a single universal wheel with no compiled dependencies beyond wasmtime. Active maintenance (last commit 2026-07-24, released 21 days ago). Requires Python 3.11+; runs on Linux, macOS, Windows (x86_64 + arm64).

License in practice

MIT license (permissive) — you may use, modify, and distribute freely with minimal restrictions, provided you retain the license notice.

Quickstart

pip install quickjs-rs

from quickjs_rs import Runtime

with Runtime() as rt:
    with rt.new_context() as ctx:
        result = ctx.eval("1 + 2")
        print(result)  # 3

Requires Python 3.11+. wasmtime must be available as a runtime dependency (installed automatically).

Verify before relying

  • Performance characteristics and overhead compared to native JS runtimes or other Python JS bindings
  • Completeness of ES module resolution and TypeScript support relative to production use cases
  • Snapshot serialization format stability and forward/backward compatibility guarantees

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.11)
Install friction low — pure-Python wheel
Runtime dependencies 1 — wasmtime
Maintenance actively maintained — 21 days since the last release
Last repo commit
First released
Downloads 305,638/month — #7,793 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: quickjs_rs-0.2.5-py3-none-any.whl

Keywords: javascript, quickjs, sandbox, wasm, wasmtime

Development Status :: 3 - AlphaIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Topic :: Software Development :: Interpreters

Tags

sandboxed javascript execution pythonrun js code from pythonwasm javascript interpreterquickjs python bindingjavascript sandbox wasmasync javascript pythones modules javascript python
javascript-sandboxwasm-runtimeasync-bridge

More Interpreters packages