Bookmarklet Creator
Create draggable bookmarklets from JavaScript code. Automatically encode and minify your code for browser bookmarks.
About Bookmarklet Creator
Overview
Bookmarklets are JavaScript snippets saved as browser bookmarks that execute code when clicked. This tool simplifies creation by automatically encoding and minifying your JavaScript, then providing a draggable button you can add directly to your bookmarks bar. Optionally customize the button name for easy identification.
Features
- Automatic code minification and URI encoding
- Drag-and-drop installation to bookmarks bar
- IIFE wrapping to prevent scope pollution
- Custom button naming for easy identification
- Copy-to-clipboard fallback for manual bookmark creation
- Comment removal (block and inline comments)
- Real-time error detection and messages
- Works completely in your browser (100% private)
How to Use
- Paste your JavaScript code into the editor
- Optionally enter a custom button name (e.g., "Dark Mode", "Print")
- Click "Generate Bookmarklet"
- Drag the generated button to your bookmarks bar, or copy the URL and manually create a bookmark
- Click your new bookmarklet whenever you want to run the code
FAQ
Can I access external libraries in my bookmarklet?
Yes. You can dynamically load libraries using fetch() or by injecting script tags. For example, to use jQuery: `var s=document.createElement("script");s.src="https://code.jquery.com/jquery-3.6.0.min.js";document.head.appendChild(s);` Then add your jQuery code after a timeout.
How do I access the current page in my bookmarklet?
You have full access to `document`, `window`, and the DOM. You can select elements with `document.querySelectorAll()`, modify content, extract data, or trigger actions. For example: `document.body.style.backgroundColor="black"` inverts the page colors.
Why do I need IIFE wrapping?
IIFE (Immediately Invoked Function Expression) wrapping prevents your bookmarklet from polluting the global namespace with variables. Without it, your variables could conflict with other scripts on the page, potentially breaking functionality.
Can I use modern JavaScript features?
Most modern features (ES6+) work fine in bookmarklets since they run in your browser. However, `import` statements won't work—use dynamic `fetch()` or script injection for external code. Arrow functions, template literals, and async/await all work great.
How do I make bookmarklets work on all websites?
Write defensive code that checks for elements before using them: `if (document.querySelector("#myElement")) { ... }`. Avoid hardcoding selectors from specific sites. Some sites block scripts via CSP headers—there's no workaround for that.