An embeddable Python REPL powered by Pyodide
npm install pyrepl-webAn embeddable Python REPL, powered by Pyodide.
Include the script and use the web component:
``html
`
That's it! No install needed.
- Python 3.13 in the browser via WebAssembly (Pyodide)
- Syntax highlighting powered by Pygments
- Tab completion for modules, functions, and variables
- Command history with up/down arrows
- Smart indentation for multi-line code
- Keyboard shortcuts: Ctrl+L (clear), Ctrl+C (cancel)
- PyPI packages: preload popular libraries
- Startup scripts: run Python on load to set up the environment
- Theming: built-in dark/light themes or fully custom
| Attribute | Description | Default |
|-----------|-------------|---------|
| theme | Color theme name (builtin or registered via window.pyreplThemes) | catppuccin-mocha |packages
| | Comma-separated list of PyPI packages to preload | none |repl-title
| | Custom title in the header bar | Python REPL |src
| | Path to a Python startup script (see below) | none |no-header
| | Hide the header bar (boolean attribute) | not set |no-buttons
| | Hide copy/clear buttons in header (boolean attribute) | not set |readonly
| | Disable input, display only (boolean attribute) | not set |no-banner
| | Hide the "Python 3.13" startup banner (boolean attribute) | not set |
Use src to preload a Python script that sets up the environment:
`html`
The script runs silently to populate the namespace. If you define a setup() function, it will be called after loading and its output is visible in the terminal:
`pythonsetup.py
import pandas as pd
df = pd.DataFrame({'name': ['Alice', 'Bob'], 'age': [30, 25]})
def setup():
print("DataFrame loaded:")
print(df)
`
Built-in themes: catppuccin-mocha (dark, default) and catppuccin-latte (light).
#### Custom Themes
Register custom themes via window.pyreplThemes before loading the script. Only background and foreground are required - everything else is automatically derived:
`html
`
What gets auto-derived from your background color:
- Terminal colors (red for errors, green for success, etc.) - from catppuccin-mocha (dark) or catppuccin-latte (light)
- Syntax highlighting - uses the matching catppuccin Pygments style
- Header colors - derived from the base theme
#### Theme Properties
| Property | Description |
|----------|-------------|
| background | Terminal background color (required) |foreground
| | Default text color (required) |headerBackground
| | Header bar background (optional) |headerForeground
| | Header title color (optional) |promptColor
| | Prompt >>> color - hex (#7aa2f7) or name (green, cyan) (optional) |pygmentsStyle
| | Custom syntax highlighting (optional, see below) |
#### Syntax Highlighting
Syntax highlighting uses Pygments. The style is chosen automatically:
1. If your theme name matches a Pygments style (e.g., monokai, dracula), that style is usedcatppuccin-mocha
2. Otherwise, uses for dark backgrounds or catppuccin-latte for light backgrounds
For full control, provide a pygmentsStyle mapping Pygments tokens to colors:
`html``