Jeremy Hou1k downloadsInstantly turns messy AI output into clean Obsidian notes on paste. Removes excessive blank lines, fixes code blocks, headers, removes emojis, and more.
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, broken LaTeX math, emojis, and more. 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.
| Feature | Original AI Paste | With Clean AI Paste |
|---|---|---|
| Headers | ### **Introduction** |
### Introduction |
| Blank Lines | Several blank lines between paragraphs | Exactly one |
| Headings | Text## HeadingBody |
Text## HeadingBody |
| ASCII Tables | +---+ +---+ (alignment collapsed) |
+---+ +---+ (spacing preserved) |
| Code Blocks | python```print("hi")``` |
```pythonprint("hi")``` |
| Math (LaTeX) | \( x = y \) |
$ x = y $ |
| Tracking URLs | https://example.com/?utm_source=chatgpt.com |
https://example.com/ |
Clean AI Paste runs automatically. Just press Ctrl+V or Cmd+V to paste from anywhere into your Obsidian note.
Under Standard, two sub-options control the blank lines around headings. Obsidian already renders headings with space above and below, so both are usually redundant in the source.
?utm_source=, ?gclid=, ?fbclid=, etc.) from pasted URLs.**## Header** → ## Header).**[Link](url)** → [Link](url)).# → ##). Capped at ######.\(, \), \[, \]) to Obsidian's native $ and $$. Leaves content inside inline code untouched.--- separators so they render correctly. (A heading placed directly after a rule is always kept tight against it — see below.)`code`. Blocks with a language label (like ```python) and multi-line blocks are always kept as full blocks. (Off by default.)Note: For some AI chats, you may need to copy a bit above or below the selected codeblock for the language to be detected, otherwise it would paste as a plain code block.
```xml) with its indentation intact, instead of being pasted as raw tags that Obsidian's renderer would swallow.python line above an unlabeled fence) and binds them into the opening backticks (```python).Ctrl+V paste is formatted. Bypass paste never notifies.Ctrl+V or Ctrl+Shift+V) opens a wide popup showing three panels: the raw text/plain, the raw text/html, and the plugin's formatted output. Each panel has a Copy button, and you can choose which version to insert — useful for understanding exactly why a paste looks the way it does, and for filing a bug report.Ctrl+Shift+V already does this by default, it is mainly useful if you have turned Legacy paste on and want a one-off raw paste without switching it back. Ships without a hotkey.These actions happen on every external paste, regardless of your settings:
Ctrl+V, content copied from inside Obsidian passes through completely untouched; the plugin's formatting only activates for content from outside (browsers, AI chat interfaces, etc.).text/html from the clipboard and converts it to native Markdown using Obsidian's built-in engine, preserving headings, bold, lists, links, and code blocks. Text copied with meaningful alignment (ASCII tables, diagrams, indented code) becomes a code block, since that is the only way Obsidian keeps the spacing.| --- | --- |) follows the header, so ASCII line art is left alone.Everything in the Features section is applied on top of this baseline and can be individually toggled and customized.
main.js and manifest.json into YourVault/.obsidian/plugins/clean-ai-paste/.Simply copy and paste whatever text using the standard shortcut: Ctrl+V (Windows/Linux) or Cmd+V (macOS). All formatting rules fire instantly and automatically.
To bypass the plugin's formatting pipeline, use: Ctrl+Shift+V (Windows/Linux) or Cmd+Shift+V (macOS).
Bypass paste inserts the clipboard's raw plain text, exactly as copied. No Markdown conversion, no formatting rules — spacing and indentation survive byte-for-byte, so ASCII tables, aligned terminal output and indented code paste intact. It's the fallback for when a normal paste formats something the way you didn't want.
Because it skips conversion entirely, raw text has no code fences, and content from sites that generate list bullets in CSS will lose those bullets — use a normal Ctrl+V when you want that structure.
<br> tags rather than proper <code> blocks on the clipboard. When this happens, it's impossible for the plugin's parser to detect it as code, and it will be pasted as plain text.If you encounter a bug, have a feature request, or want to suggest an improvement, please open an issue on the GitHub repository.
Issue templates are provided to make reporting bugs and requesting features as quick and easy as possible!
If you find this plugin useful, please leave a star on GitHub or consider supporting its development!