# Clean AI Paste for Obsidian **Clean AI Paste** is an Obsidian plugin designed to automatically clean up and format text pasted from AI chatbots (ChatGPT, Claude, Gemini, etc.) instantly and silently, every time you paste. When you copy text from an AI web interface, the result in Obsidian is often cluttered with excessive blank lines, malformed code blocks, over-bolded headers, and broken LaTeX math. This plugin intercepts the paste event, converts the clipboard HTML to native Markdown, and applies a fully customizable set of formatting rules before inserting it into your note. --- ## Main Features Before & After | Feature | Original AI Paste | With Clean AI Paste | | :--------------- | :---------------------------------------------- | :---------------------------------------- | | **Headers** | `### **Introduction**` | `### Introduction` | | **Blank Lines** | `Paragraph.`

`Next paragraph.` | `Paragraph.`
`Next paragraph.` | | **Code Blocks** | `python`
` ``` `
`print("hi")`
` ``` ` | ` ```python `
`print("hi")`
` ``` ` | | **Math (LaTeX)** | `\( x = y \)` | `$ x = y $` | | **Tracking URLs**| `https://example.com/?utm_source=chatgpt.com` | `https://example.com/` | --- ## Features ### Formatting & Cleanup - **Condense Blank Lines** - Strips excessive vertical spacing generated by AI between paragraphs, lists, and sections. - **Strip Trailing Whitespaces** - Removes invisible trailing spaces at the end of every line. - **Strip Emojis** - Removes all emoji characters from pasted text. - **Clean Link Tracking Parameters** - Automatically removes marketing and tracking parameters (e.g., `?utm_source=chatgpt.com`) from URLs in pasted text while preserving important query parameters. ### Markdown Elements - **Unbold Headers** - Strips bold markers (`**` or `__`) from Markdown headers (`**## Header**` → `## Header`). - **Unbold Links** - Removes bold formatting wrapped around links (e.g., `**[Link Text](url)**` → `[Link Text](url)`). - **Header Downgrade Level** - Automatically shifts pasted headers down by 1, 2, or 3 levels (e.g., `#` → `##`). - **Convert Math Delimiters** - Converts LaTeX delimiters (`\(`, `\)`, `\[`, `\]`) into Obsidian's native `$` and `$$`. - **Format Horizontal Rules** - Ensures proper blank-line padding around `---` separators. - **Padding Before/After Code Blocks** - Independently control whether a blank line is inserted before and after every code block. ### Code Block Intelligence - **Detached Language Labels** - Automatically detects floating language names (e.g., a bare line reading `python` above an unlabeled code block) and binds them into the opening backticks (` ```python `). - **Duplicate Label Removal** - Detects and removes the redundant language label that Claude generates when copying manually (e.g., `bash` floating above ` ```bash`). - **Indentation Stripping** - Automatically left-aligns code blocks that are deeply indented inside numbered lists or step-by-step instructions. ### Other - **Add Tracking Signature** - Wraps pasted text with fully customizable hidden HTML comments (invisible in Reading View) to track AI-generated text in source. The start and end tags are independently configurable and can be toggled on/off. - **Enable Paste Notifications** - Shows a brief Obsidian `Notice` popup when the plugin fires (off by default). - **Ignore Formatting with `Shift+Ctrl/Cmd+V`** - Paste with markdown structure preserved but no plugin transforms applied. --- ## How to Use Simply paste from your AI tool of choice using the standard shortcut: - **Windows / Linux:** `Ctrl+V` - **macOS:** `Cmd+V` All formatting rules fire instantly and automatically. To bypass the plugin entirely and paste unformatted text, use `Shift+Ctrl+V` or `Shift+Cmd+V`. --- ## Settings All rules are individually toggleable from **Settings → Clean AI Paste**. Settings are organized into three sections: 1. **Formatting & Cleanup** - Global text cleanup rules. 2. **Markdown Elements** - Rules for specific Markdown syntax. 3. **AI Tracking & Notifications** - Source-level tracking and user feedback. --- ## Installation ### From the Community Plugin Store _(Recommended)_ 1. Open Obsidian and go to **Settings → Community plugins**. 2. Disable **Restricted mode** if prompted. 3. Click **Browse** and search for **Clean AI Paste**. 4. Click **Install**, then **Enable**. ### Manual Installation 1. Download the latest release from the [GitHub repository](https://github.com/GoSlowPoke168/obsidian-clean-ai-paste). 2. Copy the `main.js` and `manifest.json` files into a new folder at `YourVault/.obsidian/plugins/clean-ai-paste/`. 3. In Obsidian, go to **Settings → Community plugins**, refresh Obsidian, find **Clean AI Paste**, and toggle it **ON**. --- ## Compatibility - **Obsidian:** 0.15.0+ - **Platform:** Desktop and Mobile (iOS & Android) --- ## License [MIT License](LICENSE)