Search...Search plugins and themes...
⌘K
Sign in
  • Get started
  • Download
  • Pricing
  • Enterprise
  • Account
  • Obsidian
  • Overview
  • Sync
  • Publish
  • Canvas
  • Mobile
  • Web Clipper
  • CLI
  • Learn
  • Help
  • Developers
  • Changelog
  • About
  • Roadmap
  • Blog
  • Resources
  • System status
  • License overview
  • Terms of service
  • Privacy policy
  • Security
  • Community
  • Plugins
  • Themes
  • Discord
  • Forum / 中文论坛
  • Merch store
  • Brand guidelines
Follow us
DiscordTwitterBlueskyThreadsMastodonYouTubeGitHub
© 2026 Obsidian

Snippets plugin

cristianvasquezcristianvasquez6k downloads

Execute simple scripts/snippets. This plugin is experimental.

Add to Obsidian
  • Overview
  • Scorecard
  • Updates3

📌 Note: Looking for a more up-to-date and actively maintained plugin with similar functionality? Check out obsidian-execute-code.

This plugin allows you to run Python, Javascript etc, snippets from inside obsidian.md

It's intended for simple uses, like starting a service, running a program, etc. I've tested this only in Linux, and is experimental.

The plugin reads your 'snippet plugin settings' that contain the configuration for each language.

Usage

Preview mode

The plugin shows a 'run' button for a recognized (shell) snippet.

preview mode example

If you click, firefox opens.

Edit mode

  1. Place your cursor on top of a code snippet.

write mode example

  1. press Ctrl/Cmd+Shift+Enter, or select the Snippets: Run command from the palette

The code will (hopefully) run, and any outputs will be appended after the snippet.

write mode example result

You can also invoke some python!

write mode python result

Vars

The following placeholders are recognized:

{{vault_path}} path of the vault
{{folder}} name of the folder
{{file_name}} Name of the file
{{file_path}} absolute path of the file

Example

echo {{vault_path}} 
echo {{folder}} 
echo {{file_name}} 
echo {{file_path}}
/home/cvasquez/obsidian
snippets-plugin
readme.md
/home/cvasquez/obsidian/snippets-plugin/readme.md
    

Config

This is the config by default. It contains one entry for each language.

{
  "python": {
    "template": "python3 -c \"{{src}}\"",
    "showModal": true,
    "appendOutputContents": true,
    "showRunButtonInPreview": true
  },
  "javascript": {
    "template": "node -e \"{{src}}\"",
    "showModal": true,
    "appendOutputContents": true,
    "showRunButtonInPreview": true
  },
  "sh": {
    "template": "{{src}}",
    "showModal": true,
    "appendOutputContents": true,
    "showRunButtonInPreview": true
  }
}

Attributes

Template {{src}} will be replaced
showModal shows the output in a modal
appendOutputContents writes the output after the code fence
showRunButtonInPreview shows the button in the preview mode
options additional options such as shell or encoding

Default shell

The default shell is '/bin/sh' on Unix and process.env.ComSpec on Windows. Other shells can be configured using the 'options' attribute.

Example that uses powershell:

  "sh": {
    "template": "{{src}}",
    "options": {"shell":"powershell.exe"},
    "showModal": true,
    "appendOutputContents": true,
    "showRunButtonInPreview": true
  }

Manual installation

Install dependencies

npm install

Generate main.js bundle

npm run build

Copy main.js, manifest.json and styles.css to your vault's plugins folder, under [YourVaultFolder]/.obsidian/plugins/review-obsidian/.

Observations

This prototype is super experimental; I've written it because I wanted to use python inside obsidian.

Developers

Pull requests are both welcome and appreciated. :)

Version

0.0.4

  • Added javascript option.
  • Added shell options.
  • No errors when markdown view is not present.

Thanks to:

  • catworld
  • mgmeyers
HealthFair
ReviewCaution
About
Run code snippets (Python, JavaScript, shell, etc.) directly from notes and append their output after the code fence or display it in a modal. Recognize and run snippets in preview via a run button or invoke the Run command in edit mode; use placeholders like {{vault_path}}, {{folder}}, {{file_name}} and {{file_path}}.
CodeAutomationDevelopers
Details
Current version
0.0.4
Last updated
5 years ago
Created
6 years ago
Updates
3 releases
Downloads
6k
Compatible with
Obsidian 0.9.12+
Platforms
Desktop, Mobile
License
MIT
Report bugRequest featureReport plugin
Author
cristianvasquezcristianvasquez
github.com/cristianvasquez
GitHubcristianvasquez
  1. Community
  2. Plugins
  3. Code
  4. Snippets plugin

Related plugins

CodeScript Toolkit

Allows to do a lot of things with JavaScript/TypeScript scripts from inside the Obsidian itself

BRAT

Easily install a beta version of a plugin for testing.

Hot Reload

Automatically reload in-development plugins when their files are changed

Templater

Create and use dynamic templates.

CustomJS

Reuse custom JavaScript across desktop and mobile.

Homepage

Open a note, base, or workspace on startup, or set it for quick access later.

Advanced URI

Control everything with URI.

Claudian

Embeds Claude Code/Codex and other local Agents as AI collaborators in your vault.

Local REST API with MCP

Unlock your automation needs by interacting with your notes over a secure REST API.

Lazy Loader

Load plugins with a delay on startup, so that you can get your app startup down into the sub-second loading time.