How to Create Chrome Extension
In this article
Yes, you can create a Chrome extension using only HTML, CSS, and JavaScript. This guide walks you through building a simple extension that adds a button to the Chrome toolbar, which displays a popup when clicked. You don’t need a server or backend—everything runs locally in the browser. The process involves creating a manifest file, designing a popup interface, and testing it directly in Chrome.
What You'll Need
- A computer with Chrome installed (Windows, Mac, or Linux)
- A text editor (like VS Code, Sublime Text, or Notepad++)
- Basic knowledge of HTML, CSS, and JavaScript
- A folder to store all extension files
Step-by-Step
- Create a new folder on your computer for your extension. Name it something like
my-chrome-extension. - Inside this folder, create a file named
manifest.json. This file tells Chrome about your extension, including its name, version, and permissions. - Open
manifest.jsonin your text editor and add the following code:{ "manifest_version": 3, "name": "My First Extension", "version": "1.0", "description": "A simple extension to display a popup", "action": { "default_popup": "popup.html", "default_icon": { "16": "images/icon16.png", "48": "images/icon48.png", "128": "images/icon128.png" } }, "icons": { "16": "images/icon16.png", "48": "images/icon48.png", "128": "images/icon128.png" } }Note: Chrome uses Manifest V3 as the current standard. Theactionfield defines what happens when the user clicks the extension icon. - Create an
imagesfolder inside your extension folder. Add three icon files sized 16x16, 48x48, and 128x128 pixels. You can use PNG files. If you don’t have icons, you can temporarily skip this and use placeholder files. - Create a file named
popup.htmlin the main folder (same level asmanifest.json). This will be the content shown when the user clicks the extension icon. - Open
popup.htmland add the following code:<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <style> body { width: 300px; padding: 10px; font-family: Arial, sans-serif; } h1 { font-size: 18px; margin: 0; } button { margin-top: 10px; padding: 8px; } </style> </head> <body> <h1>Hello from My Extension!</h1> <button id="clickMe">Click Me</button> <script src="popup.js"></script> </body> </html>This creates a simple popup with a heading and a button. - Create a file named
popup.jsin the same folder. This will add interactivity to the popup. - Add this JavaScript code to
popup.js:document.getElementById('clickMe').addEventListener('click', function() { alert('Button was clicked!'); });This listens for clicks on the button and shows an alert. - Open Chrome and go to
chrome://extensions. Make sure Developer mode is turned on in the top-right corner. - Click "Load unpacked" and select your extension folder (e.g.,
my-chrome-extension). - If there are no errors, your extension will appear in the list. A puzzle-piece icon will show in the toolbar. Click it to see your popup.
- Test the button. Clicking it should show an alert saying "Button was clicked!".
Common Mistakes
- Forgetting to enable Developer mode on the
chrome://extensionspage—this is required to load unpacked extensions. - Using an incorrect manifest version—Chrome now requires Manifest V3. Using V2 will cause loading to fail.
- Missing commas or brackets in
manifest.json—JSON is strict about syntax. One typo will prevent the extension from loading. - Not including required fields like
name,version, andmanifest_version—these are mandatory. - Referencing files that don’t exist—ensure
popup.html,popup.js, and icon paths are correct and spelled exactly.
Tips
- Use relative paths in the manifest and HTML files. Chrome resolves them from the extension root.
- Keep your extension lightweight—avoid large images or unnecessary scripts.
- Test changes frequently. After editing files, click "Reload" on the extension in
chrome://extensionsto see updates. - Add comments to your code for clarity, especially in larger projects.
- Use the browser’s developer tools by right-clicking the popup to inspect elements and debug JavaScript.
Troubleshooting
If your extension doesn’t load, start with these steps:
- Check the error message on
chrome://extensions. It often points to the exact line with a JSON syntax error. - Ensure Developer mode is enabled. Without it, the "Load unpacked" button won’t appear.
- Verify that
manifest.jsonis in the root folder and contains valid JSON. Use an online JSON validator if needed. - Confirm that
popup.htmlexists and is spelled correctly in both the file system and the manifest. - If the popup opens but the button doesn’t work, open the popup, right-click, and select "Inspect" to check for JavaScript errors in the console.
- Try closing and reopening Chrome if the extension behaves unexpectedly after multiple reloads.
Frequently Asked Questions
Can I create a Chrome extension without coding?
No, you need at least basic HTML, CSS, and JavaScript knowledge. There are no official no-code tools from Google for building extensions.
Can my extension access web page content?
Yes, but you need to declare permissions in the manifest and use content scripts. This requires additional configuration beyond this basic example.
How do I publish my extension?
Go to the Chrome Developer Dashboard, sign in with your Google account, and upload your extension folder as a ZIP file. You’ll need to pay a one-time $5 registration fee.
Can Chrome extensions run in other browsers?
Some browsers like Edge and Brave support Chrome extensions, but compatibility isn’t guaranteed. Always test in the target browser.
Why does my popup close when I click a button?
Popups automatically close when they lose focus. To keep them open, you need to use persistent UI elements like options pages or side panels instead.
Can I use external libraries like jQuery?
Yes, but you must include the library file in your extension folder and reference it in popup.html. Avoid loading scripts from external URLs for security reasons.