Skip to content

GoSlowPoke168/obsidian-clean-ai-paste

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Clean AI Paste for Obsidian

Downloads Release Latest Release

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.


Quick Look: 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

Clean AI Paste runs automatically. Just press Ctrl+V or Cmd+V to paste from anywhere into your Obsidian note.

Spacing Normalization

  • Standard — Natural line and paragraph spacing with comfortable room to breathe.
  • Tight — Removes all blank lines everywhere.
  • Off — Leaves all spacing completely untouched.

Formatting & Cleanup

  • Strip Trailing Whitespaces — Removes invisible trailing spaces at the end of every line.
  • Strip Emojis — Removes all emoji characters from pasted text. An optional allowlist lets you preserve specific ones.
  • Strip Link Tracking Parameters — Removes tracking parameters (?utm_source=, ?gclid=, ?fbclid=, etc.) from pasted URLs.

Markdown Elements

  • Unbold Headers — Strips bold markers from Markdown headers (**## Header**## Header).
  • Unbold Links — Removes bold formatting wrapped around Markdown links (**[Link](url)**[Link](url)).
  • Header Downgrade Level — Shifts pasted headers down by 1–3 levels (e.g. ###). Capped at ######.
  • Convert Math Delimiters — Converts AI-style LaTeX (\(, \), \[, \]) to Obsidian's native $ and $$. Leaves content inside inline code untouched.
  • Format Horizontal Lines — Ensures a blank line both before and after --- separators so they render correctly. (A heading placed directly after a rule is always kept tight against it — see below.)
  • Padding Before/After Code Blocks — Independently control whether a blank line is inserted before and after every fenced code block.
  • Inline Single-Line Code Blocks — Converts a fenced code block containing only one line (e.g. a copied one-line command) into inline `code`. Blocks with a language label (like ```python) and multi-line blocks are always kept as full blocks. (Off by default.)

Code Block Intelligence (Always Active)

  • Detached Language Labels — Detects floating language names (e.g., a bare python line above an unlabeled fence) 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).

AI Tracking & Notifications

  • Add Tracking Signature — Wraps pasted text with hidden HTML comments (invisible in Reading View) to mark AI-generated content in source mode. The start and end tags are independently configurable.
  • Enable Paste Notifications — Shows a brief notice in the corner each time the plugin processes a paste.

Troubleshooting

  • Debug/Preview Mode — When enabled, pasting (either 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. You can inspect all three and choose which to insert — useful for understanding exactly why a paste looks the way it does.
  • Reset settings to default — A button at the bottom of the settings tab to instantly restore all toggles to their original state.

Baseline Behavior (Always Active)

These actions happen on every external paste, regardless of your settings:

  1. External paste interception — On a normal 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.). (A bypass Ctrl+Shift+V with Keep Markdown structure on bypass enabled may still apply its light cleanup to internal content — use a normal Ctrl+V for a truly untouched internal paste.)
  2. HTML → Markdown conversion — Reads 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.
  3. Table & blockquote padding — Always adds a blank line before/after tables and after blockquotes so they render correctly in all Markdown contexts. This cannot be toggled off, but it only adds lines where they are structurally required.

Everything in the Features section is applied on top of this baseline and can be individually toggled and customized.


Installation

From the Community Plugin Store (Recommended)

  1. Open Obsidian → Settings → Community plugins.
  2. Disable Restricted mode if prompted.
  3. Click Browse, search for Clean AI Paste, click Install then Enable.

Manual Installation

  1. Download the latest release from the GitHub repository.
  2. Copy main.js and manifest.json into YourVault/.obsidian/plugins/clean-ai-paste/.
  3. In Obsidian, go to Settings → Community plugins, find Clean AI Paste, and enable it.

How to Use

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.

Bypass Paste

To bypass the plugin's formatting pipeline, use: Ctrl+Shift+V (Windows/Linux) or Cmd+Shift+V (macOS). Bypass paste never wraps content in a code fence, and it skips every formatting rule from the Features section.

What it inserts depends on the Keep Markdown structure on bypass toggle in the settings (on by default):

  • Toggle on — Keeps the Markdown structure of the copied content (headings, lists, tables, bold, links), since the plain-text version from many sites has no list numbers, heading marks, or table pipes at all. Then applies only minimal cleanup: condensing blank lines (following the Spacing normalization setting — e.g. set it to "Off" and bypass will leave blank lines untouched too), padding tables so they render, and stripping trailing whitespace. Code is still never wrapped in a fence.
  • Toggle off — Inserts the clipboard's raw plain text exactly as copied, completely untouched.

Known Limitations

  • Code blocks missing HTML structure: Sometimes when copying code, it will just copy as plain text and <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.

Compatibility

  • Obsidian: 0.15.0+
  • Platform: Desktop and Mobile (iOS & Android)

Feedback & Bug Reports

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!


License

GitHub License


Support the Project

If you find this plugin useful, please consider giving it a star on GitHub or consider supporting its development!

Buy Me A Coffee

About

Instantly turns messy text pasted from AI chatbots like ChatGPT, Claude, and Gemini into clean Markdown notes. Removes excessive blank lines and emojis, fixes code blocks, headers, and more.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages