alecell1k downloadsReplace text in your notes automatically using regex rules and JavaScript functions.
Auto Replacer is a powerful plugin for Obsidian that automatically replaces text in your notes using custom rules powered by regex and JavaScript.
Whether you want to format units, highlight keywords, or inject smart, context-aware replacements like the note title, Auto Replacer gives you full control over text automation in your vault.
Each rule consists of:
\bkm\b)*kilometers*)Example:
// Match the note title and make it bold
function transformNoteTitle(occurrence, editor, file) {
const noteName = file?.basename;
if (!noteName) return occurrence.original;
return `**${noteName}**`;
}
| Name | Text | Pattern | Replace With |
|---|---|---|---|
| Replace Note Title | world of pados | (?<!\*\*)\b{{file.basename}}\b(?!\*\*) |
**World of Pados** |
| Replace Comma Decimal | 27,6 | \b\d+,\d+\b |
27.6 |
| Replace Fahrenheit | 64.4 °F | \b\d+(\.\d+)?\s?°?\s?F\b |
18 °C |
| Emphasize Measurement | 49 km | \b\d+(?:\.\d+)?\s\*(?:km|mi|kg|g|m)\b |
*49 km* |
Open Settings → Auto Replacer
Click "Add custom rule"
Fill out:
Rule nameRule IDRegex pattern and FlagsReplacement code (in JavaScript)Description (optional)Save and type in any note — the rule applies automatically
editor and file objects inside your transform code{{file.basename}} as a dynamic variable in regex patternseditor-change for performanceThe Auto Replacer plugin allows you to write and execute custom JavaScript functions to dynamically transform matched content within your notes. These functions are executed locally, directly in your Obsidian vault, and are never transmitted anywhere.
However, executing arbitrary code — even if it looks innocent — can have unintended consequences. You have full control over what the plugin runs, which also means you take full responsibility for what it does. A simple typo can break your notes. A badly written loop can slow down your editor. And a malicious snippet (if ever copied from somewhere) could do far worse.
So please — only run code that you fully understand.
Auto Replacer offers you the power to automate and enhance your note-taking... But as a certain wise uncle once said:
With great power comes great responsibility.
| Section | Link |
|---|---|
| Learn More | 📚 Documentation |
| Plugin on GitHub | 🔗 GitHub Repo |
| Submit Issue | 🐛 Report |
Creating and maintaining this plugin takes time, research, and a lot of coffee (or should I say... dragons?).
If you found AutoReplacer useful and want to support its development, consider fueling it with a mythical boost!
Your support helps improve the plugin and means a lot 💛
Created with ❤️ by Alecell. Special thanks to sailKite!
MIT License © Alecell