Turn JavaScript into a bookmarklet

Paste a small script, generate the bookmark URL, then drag the result to your bookmarks bar. Your code stays local.

What a bookmarklet actually is

A bookmarklet is an ordinary browser bookmark whose address starts with javascript:instead of https:. Open a page, click the bookmark, and the browser runs your script against that page instead of navigating anywhere. Bookmarklets are useful for page-specific actions — copying a formatted citation, toggling a reading view, extracting selected text, or opening the current URL in another service. They require no extension installation, request no permissions, and live in the bookmarks bar like any other link.

How this generator works

The tool does two things to your snippet. First, it wraps the code in an immediately-invoked function — (() => { … })() — so your variables can't collide with whatever the target page already defines. Second, it percent-encodes the script, because a bookmark address cannot safely contain raw spaces, quotes, or several other characters. The result is the longjavascript:… string you drag to the bar. All of this happens inside this page: the generator never sends your code to a server.

How to make and install a bookmarklet

  1. Give the bookmark a name and paste your JavaScript into the code box — or press Load page-title sample to see a finished example.
  2. Press Create bookmarklet. The generated URL appears below.
  3. Drag the dark button onto your bookmarks bar. If the bar is hidden, enable it from your browser's View menu first.
  4. No drag-and-drop (touch devices, for instance)? Create a new bookmark manually and paste the generated URL into its address field. If a browser strips the javascript: prefix when you type in the address bar, the bookmark editor keeps it as entered.
  5. Open any page and click the bookmark. The script runs once, against that page.

Common bookmarklet uses

GoalWhat the script does
Copy a citationWrites the page title and URL to the clipboard — the sample built into this page.
Extract selected textReads the current selection and copies or reformats it.
Reveal hidden contentOverrides CSS that clips overflowing text so collapsed sections become visible.
Preview a style changeTemporarily recolors or restyles the page; a reload undoes it.
Send the page elsewhereOpens the current URL in a search, translation, or archive service.
Audit the pageCounts elements — images, links, scripts — and reports the totals.

Security matters

A bookmarklet runs with the same access the page's own scripts have: it can read and change anything the page exposes. Review code before installing it, avoid snippets that load remote scripts — a URL someone else controls can change after you install — and never run an unknown bookmarklet on a page containing sensitive information. Pages served with a strict Content-Security-Policy may refuse to run bookmarklets at all; that is the site protecting its users, not a bug in this generator.

Bookmarklet vs userscript vs extension

The three look similar but answer different needs. A bookmarklet is one script that runs once, on one page, when you click it — zero installation, and it travels with your bookmarks. A userscript (managed by a userscript manager) attaches to matching sites and can run automatically on every visit, keeping its own settings between pages. Abrowser extension can do both of those and more — background work, network interception, toolbar icons — at the cost of an install step and broad permissions that the browser surfaces to you up front. Start with the bookmarklet; upgrade only when you hit its limits.

Limits: when not to use a bookmarklet

A bookmarklet only runs when you click it, on one page at a time. It cannot keep state between visits, act in the background, or modify every page automatically. Very long scripts technically fit, but become unreadable bookmark URLs — at that size a userscript manager or extension is the right tool. And if the job is "save this page with one click" rather than "run a snippet," a purpose-built browser extension does it without maintaining code.

Privacy: where your code goes

Nowhere. The name, the snippet, and the generated URL never leave the page — there is no network request involved in building a bookmarklet. One honest caveat: the finished bookmarklet is stored as a normal bookmark, so if you sync bookmarks across devices, the script travels with your other bookmarks and is visible to anything that can read that synced profile.

Related

Curious about the percent-encoding step the generator performs? Try theURL encoder and decoder on any string. For saving and working with pages without writing script at all, see Marqly's web highlighter, the bookmark manager for Chrome, and the second-brain workflow — or read the guide onhow to organize bookmarks.

Frequently asked questions

What is a bookmarklet?

A bookmarklet is a browser bookmark whose URL starts with javascript:. Clicking it runs a small script on the page you are viewing instead of opening another website.

How do I install the generated bookmarklet?

Drag the generated button to your bookmarks bar. If drag-and-drop is unavailable, copy the bookmarklet URL and paste it into the URL field of a manually created bookmark.

Is the code executed by this generator?

No. This page only packages and displays the code. The generated button is prevented from running here; it executes only when you save it as a bookmark and click it on another page.

Are bookmarklets safe?

A bookmarklet can read and change the current page, so only use code you understand and trust. Some websites block bookmarklets with strict security policies.

Does this generator send my script anywhere?

No. The page reads what you type, wraps it in a function, URL-encodes it, and displays the result — there is no server call in the generator, and the snippet is transformed entirely on your device.

When should I use a userscript or an extension instead of a bookmarklet?

A bookmarklet runs once, on one page, only when you click it. If you need code that runs automatically on every visit, stores its own data, or works across sites in the background, a userscript manager or a browser extension fits better.

← All free tools