Adding a bookmarklet to Chrome takes three steps: create or find the code, add it as a bookmark, and edit that bookmark to run the code instead of opening a URL

A bookmarklet is a bookmark that runs JavaScript code when you click it, rather than taking you to a website. In Chrome, you create one by saving a bookmark with JavaScript code in the URL field. When you click the bookmark, Chrome executes that code on the current page — it might highlight all links, extract text, modify the page layout, or send data somewhere else.

The process is the same whether you write the code yourself or copy it from someone else. You need the JavaScript code, a way to save it as a bookmark, and then a small edit to make Chrome treat it as executable code rather than a web address.

Key Takeaways

  • Bookmarklets are bookmarks that run JavaScript code on the current page when clicked, not links to websites.
  • You create one by opening the bookmark manager, adding a new bookmark, and pasting JavaScript code into the URL field with javascript: at the start.
  • The code must begin with javascript: followed by your script, all on one line with no line breaks.
  • You can test a bookmarklet on any webpage, and it only affects what you see in your browser — it does not change the actual website.

Finding or writing the bookmarklet code

If you are starting from scratch, you need JavaScript code that does what you want. Many bookmarklets already exist online — search for "bookmarklet" plus what you want to do, like "bookmarklet highlight all links" or "bookmarklet convert text to uppercase". Sites like Bookmarklets.com and GitHub host collections you can copy from.

If you write your own code, keep it simple at first. A basic example is javascript:alert('Hello');, which pops up a message box. More useful examples might loop through all links on a page, change the background color, or extract specific text. The code must be valid JavaScript and fit on a single line — Chrome will reject it if there are line breaks in the URL field.

When you find code online, copy the entire script exactly as written. Some sources show it with javascript: at the start, others without. Either way, you will add or confirm that prefix when you save the bookmark.

Creating the bookmark in Chrome

Open Chrome and press Ctrl+Shift+B (Windows) or Cmd+Shift+B (Mac) to show the bookmark bar at the top of the browser. Then press Ctrl+Shift+O (Windows) or Cmd+Shift+O (Mac) to open the bookmark manager in a new tab.

In the bookmark manager, click the three-dot menu in the top right and select Add new bookmark. A dialog box appears with two fields: Name and URL. In the Name field, type a short label for what the bookmarklet does — for example, "Highlight Links" or "Dark Mode". Leave the URL field empty for now; you will fill it next.

Click Save. The bookmark is now created but not yet functional. You need to edit it to add the code.

Editing the bookmark to add the code

In the bookmark manager, find the bookmark you just created. Right-click it and select Edit. The same dialog opens again, this time with the bookmark's current details.

Click in the URL field and paste your JavaScript code. Make sure it starts with javascript: with no space after the colon. For example: javascript:alert('This is a bookmarklet'); or javascript:document.body.style.backgroundColor='black';

If your code has multiple statements, separate them with semicolons and keep everything on one line. Chrome will reject the bookmark if there are line breaks in the URL field. Some longer scripts need to be wrapped in a function or compressed to fit, but most simple bookmarklets work as-is.

Click Save. The bookmark is now ready to use.

Testing the bookmarklet on a webpage

Open any webpage in Chrome. Click the bookmarklet in your bookmark bar — the one you just created. The code runs immediately on that page. If it works, you will see the result: a popup message, a color change, highlighted elements, or whatever the code was designed to do.

If nothing happens or you see an error, check that the code starts with javascript: and has no line breaks. Go back to the bookmark manager, right-click the bookmark, select Edit, and review the URL field. Common mistakes are a missing semicolon at the end, a space after javascript:, or code that was split across multiple lines when pasted.

Bookmarklets only affect what you see in your browser tab — they do not change the actual website or send data anywhere unless the code explicitly does that. You can test freely without worry.

Moving the bookmarklet to your bookmark bar for quick access

Once your bookmarklet works, you can move it to your bookmark bar so it is always visible. In the bookmark manager, find the bookmarklet and drag it to the Bookmark bar folder on the left side. Alternatively, right-click the bookmark, select Edit, and change the folder from wherever it is now to Bookmark bar.

Close the bookmark manager. The bookmarklet now appears in your bookmark bar at the top of Chrome, next to your other bookmarks. You can click it from any webpage. If you want to organize your bookmarks, you can also create folders within the bookmark bar and drag bookmarklets into them — for example, a "Tools" folder containing several utility bookmarklets.

Sharing or backing up your bookmarklets

If you want to share a bookmarklet with someone else, you can export your bookmarks from Chrome. In the bookmark manager, click the three-dot menu and select Export bookmarks. Chrome saves an HTML file containing all your bookmarks, including bookmarklets. The other person can import that file into their browser.

To share just one bookmarklet, copy the code from the URL field of the bookmark (right-click, select Edit, and copy the entire URL including javascript:). Paste it in an email or document. The recipient can create a new bookmark and paste that code into the URL field to get the same bookmarklet.

Backing up your bookmarklets this way is also useful if you reinstall Chrome or switch computers. Export your bookmarks regularly so you do not lose custom bookmarklets you have built or collected.

Frequently Asked Questions

Can I use bookmarklets on mobile Chrome?

Mobile Chrome does not support bookmarklets the same way desktop Chrome does. You can save bookmarks on mobile, but tapping them opens URLs only — they do not execute JavaScript code. Desktop Chrome is the right place for bookmarklets.

What if the bookmarklet code is very long?

Long code can be compressed or wrapped in a function to fit on one line. Many online bookmarklet collections provide minified versions designed to fit in the URL field. If you have code with line breaks, remove them and replace with semicolons between statements, or search for a minified version of the same script.

Will a bookmarklet work on every website?

Most bookmarklets work on any webpage, but some websites block JavaScript execution for security reasons. If a bookmarklet does nothing on a particular site, that site may have restrictions in place. Try it on a different website to confirm the bookmarklet itself works.

Can I edit a bookmarklet after I create it?

Yes. Right-click the bookmarklet in your bookmark bar or bookmark manager, select Edit, and change the code in the URL field. Click Save and the changes take effect immediately. This is useful if you want to tweak the behavior or fix a mistake.

What happens if I accidentally click a bookmarklet on the wrong page?

The code runs on whatever page you are viewing. If the bookmarklet is designed for a specific site, it might not do anything useful on a different site, but it will not break anything. Bookmarklets only modify what you see in your browser — they do not change the website itself or cause permanent damage.