Code Runner

approved

by chujiu-dev

Interactively run code blocks in Obsidian with stdin input support,works on desktop, iOS & Android.. Supports Python, C, C++, Java, Go, JavaScript, TypeScript, Rust, Kotlin and more. - This plugin has not been manually reviewed by Obsidian staff.

1 stars263 downloadsUpdated 21d agoMIT

Code Runner — Obsidian Plugin

Run code blocks interactively in Obsidian with full stdin input support. Python runs locally via Pyodide (WebAssembly); 17+ other languages execute via public playground APIs.

Features

Hybrid Interactive Input (Python)

Code Runner provides the most complete Python input experience of any Obsidian plugin:

PlatformModeBehavior
Desktop (SAB available)InteractivePre-fill the first input() prompt, then each subsequent input() triggers an inline popup in real time — type and press Enter as the program runs
Tablet / Mobile (no SAB)Pre-fillAll input() prompts are parsed and shown as labeled fields. Loop-based programs get a raw textarea for unlimited lines
  • Input history: Every prompt→response pair is displayed above the output, visible during and after execution
  • Stop button: Terminate runaway programs during interactive execution
  • Auto-detection: input() inside while/for loops is detected automatically; tablet mode switches to a multi-line textarea

Multi-Language Support

LanguageBackendstdin
PythonPyodide v0.26.x (local WASM)
CSoloLearn API (remote)
C++SoloLearn API (remote)
JavaSoloLearn API (remote)
GoSoloLearn API (remote)
C#SoloLearn API (remote)
SwiftSoloLearn API (remote)
RSoloLearn API (remote)
JavaScriptProxy-sandboxed eval (local)
TypeScriptCompiled → JS (local)
RustRust Playground API (remote)
KotlinKotlin Playground API (remote)
HaskellHaskell Playground API (remote)
CrystalCrystal Playground API (remote)
V (Vlang)V Playground API (remote)
Wenyanwenyan-lang CDN (local)
HTMLShadow DOM render (local)

Quality of Life

  • Output cache: Results persist across note switches via localStorage
  • ANSI color support: Terminal color codes are rendered in output
  • Matplotlib: Python matplotlib figures render inline (desktop)
  • Plugin API: Other plugins can programmatically execute code via app.plugins.plugins['code-runner'].api

Installation

Manual

  1. Download main.js, manifest.json, styles.css from the latest release
  2. Create <vault>/.obsidian/plugins/code-runner/ and copy the 3 files in
  3. Settings → Community Plugins → Enable "Code Runner"

Community Plugin (pending approval)

Once approved, install directly via Settings → Community Plugins → Browse → "Code Runner".

Usage

Create a fenced code block with a language tag:

```python
name = input("Enter your name: ")
age  = input("Enter your age: ")
print(f"Hello {name}, you are {age} years old!")
```
  • Click the ⌨ keyboard icon (bottom-right of the code block) to open the input form
  • Fill in your input values and click to run
  • Output appears below the code block

Input Format

  • Python: Each line feeds one input() call
  • C / C++ / Java / Go / C# / Swift / R: Separate values with spaces (fed to the program's stdin stream)

Architecture

Code Block → needsStdin() → Show pre-fill form (optional)
                │
          ┌─────┴─────┐
     SAB available?    │
     ┌───┴───┐         │
    Yes     No         │
     │       │         │
  Worker   Main-thread │
  + SAB    Pyodide     │
  (inter-  (pre-fill   │
  active)  only)       │
                       │
          Output ←─────┘
  • Worker + SharedArrayBuffer: Desktop mode. Atomics.wait/notify synchronously blocks the Worker for interactive input without freezing the UI
  • Main-thread Pyodide: Tablet/mobile fallback. All input must be provided before execution

Building From Source

git clone https://github.com/chujiu-dev/obsidian-code-runner.git
cd obsidian-code-runner
npm install
npm run build
# Output: dist/main.js, dist/styles.css, dist/manifest.json

Credits

Forked from Code Emitter by YISH (MIT). Key additions:

  • Hybrid stdin system: pre-fill + Worker/SAB interactive input
  • Full Python input() support via builtins.input replacement (Pyodide v0.26.x / Python 3.12)
  • Tablet/mobile fallback with auto-detection of loop-based interactive programs
  • Input history, stop button, output caching, ANSI color rendering

License

MIT — see LICENSE.

For plugin developers

Search results and similarity scores are powered by semantic analysis of your plugin's README. If your plugin isn't appearing for searches you'd expect, try updating your README to clearly describe your plugin's purpose, features, and use cases.