This page provides a bookmarklet that removes hidden characters from AI-generated text.
A bookmarklet is a small bit of JavaScript code that you save as a shortcut on your browser toolbar. Whenever you run the shortcut, the code is executed on the current page, enabling it to do things like copy text to the clipboard.
This bookmarklet grabs the selected text and looks for any hidden or special characters often generated by AI chatbots. These characters can cause problems if they get copied to a system that does not support them. The challenge is that the characters are hidden, making you unaware they are coming along with your copy/paste operation.
Workaround: paste into plain text first
this is just a test
One oft-cited workaround is to paste the AI-generated text into a text-only app such as Notepad (Windows) or Apple Notes (macOS). You then recopy the text before pasting it into the final destination. This workaround can help strip a variety of hidden characters but is not 100% reliable. It is also a clunky process.
Another workaround is to use an online text cleaner. Unfortunately, many of these sites are spammy with popup windows and questionable privacy policies. It might also be a violation of your work agreement if you are cleaning up sensitive or private text.
The bookmarklet approach
This bookmarklet makes the process easier and safer. Whenever you need to cleanup some AI-generated text, you:
- Select the text (or copy the text into your clipboard)
- Click the bookmarklet button on your bookmarks (or favorites) toolbar
- The bookmarklet cleans the text and copies the cleaned text to the clipboard
Note that no data ever leaves your browser. The text is cleaned manually in the code without calling an external website or API. You can review the code yourself for proof.
The bookmarklet source code
This version is annotated with comments so you can review understand the code.
javascript:(async function() {
try {
text = await navigator.clipboard.readText();
}
catch (e) {
throw new Error("Clipboard access was blocked.");
}
alert(text);
return;
/*
const matches=text.match(/[\u00AD\u00A0\u2007\u200B-\u200F\u202A-\u202E\u202F\u2060\u2066-\u2069\uFEFF]/g)||[];
let cleaned=text
.replace(/[\u200B-\u200F\u202A-\u202E\u2060\u2066-\u2069\uFEFF\u00AD]/g,'')
.replace(/[\u00A0\u202F\u2007]/g,' ')
.trim();
navigator.clipboard.writeText(cleaned).then(()=>{
alert(`Removed ${matches.length} hidden characters and copied cleaned text.`);
});
*/
})();How it works, technically
The bookmarks bar
This post is not completed
All modern browsers offer a bookmarks bar (sometimes called a favorites bar), which is a toolbar providing easy access to your bookmarked websites. Each bookmark is shown as a button you can click to open the website.
The javascript: URI scheme
A typical bookmark is an http: or https: URL such as https://45-61-50-197.us-se-cloud-xip.com/. However, other types of links are supported including javascript: links. A JavaScript link has the format javascript:script() where script() is the JavaScript code to execute. Here is an example:
javascript:alert("hello, world")If you add this link as a bookmark to your bookmarks or favorites bar, you’ll get a popup message with “hello, world” whenever you click it.
For more information on JavaScript links, see javascript: URLs – URIs (developer.mozilla.org).
Auto-executing JavaScript function
The JavaScript is written as an auto-executing function using the following syntax:
( function() { /* code */ } )();This syntax is known as an Immediately Invoked Function Expression (IIFE). It is a function that runs as soon as it is defined. See https://developer.mozilla.org/en-US/docs/Glossary/IIFE
Show your favorites bar
Press Control-Shift-B to open your favorites bar.

Leave a Reply