Lightweight notebook-style code execution for Obsidian Live Preview.
This plugin lets you mark a note as runnable, execute fenced code blocks inline, and view output directly under each block.
- Runs code blocks directly inside Obsidian
- Shows output inline below the block
- Supports standard fenced code blocks like
python,js,bash, and any other language you configure - Works with Live Preview and Reading view
- Lets you configure runners visually instead of editing raw JSON
- Supports extra
PATHentries for tools installed outside Obsidian's default environment
- Rendered code uses
CodeMirror - Default dark theme:
GitHub Dark - Default light theme:
GitHub Light - Built-in runner presets:
js->node {{file}}python->python3 {{file}}bash, sh->/bin/bash {{file}}
This plugin is desktop-only. It depends on local process execution and does not support Obsidian mobile.
Add this frontmatter to the note:
---
code-runner: true
---The plugin accepts both keys:
code-runnercoderunner
It also accepts boolean and quoted string values:
code-runner: true
code-runner: "true"
code-runner: 'true'
coderunner: true
coderunner: "true"
coderunner: 'true'Example:
```python
print("hello, world")
```If the language is configured in the plugin settings, the block becomes runnable.
Use the inline controls above the block:
RunStopClear- collapse output
Output appears directly below the block.
Open the plugin settings and use the Runners section.
Each runner row has:
Languages: comma-separated fence namesCommand: command template to execute
Use {{file}} where the temporary snippet file should be inserted.
Examples:
- Languages:
js, javascriptCommand:node {{file}} - Languages:
ts, typescriptCommand:npx ts-node {{file}} - Languages:
goCommand:go run {{file}}
You can map multiple languages to the same command in one row.
Some tools work in your terminal but not inside Obsidian because the app may not inherit the same shell PATH.
Use Environment PATH in the plugin settings to add extra directories. Add one directory per line.
Examples:
/usr/local/bin/opt/homebrew/bin- a custom toolchain directory
These entries are prepended to the process PATH when running code blocks.
The plugin also registers command palette actions:
Run current runnable blockStop current runnable blockClear current runnable block output
These work when your cursor is inside a runnable block.
When Rendered code renderer is set to CodeMirror, the plugin can use separate themes for dark mode and light mode.
Dark themes:
One DarkDraculaNordTokyo NightGitHub Dark
Light themes:
GitHub LightQuiet LightXcode
The plugin automatically switches between the selected dark and light theme based on Obsidian's current mode.
Install dependencies:
npm installBuild once:
npm run buildWatch build:
npm run dev- A block is only treated as runnable when the note has Code Runner frontmatter enabled.
- If a language is added in settings, it becomes runnable without reloading the plugin.
- If a command cannot be found, check the runner command and your
Environment PATHsettings.
This project is licensed under the MIT License. See LICENSE for details.