What you need to build a Chrome extension

A Chrome extension is a small program that adds features to your browser. You build one using three files: a manifest.json file that describes what your extension does, an HTML file for the user interface, and a JavaScript file for the logic. You do not need special software — a text editor like Notepad, VS Code, or Sublime Text is enough. You also need Google Chrome installed on your computer.

The manifest file is the foundation. It tells Chrome the extension's name, version, what permissions it needs, and which files to load. Without a valid manifest, Chrome will not recognize your extension at all. The HTML and JavaScript files do the actual work — they can be as simple or complex as you want.

You do not need to publish your extension to the Chrome Web Store to test it. You can load it directly into Chrome in developer mode and use it immediately on your own computer. This is how most people start building.

Key Takeaways

  • A Chrome extension requires three core files: manifest.json, an HTML file, and a JavaScript file, all in the same folder.
  • The manifest.json file must specify the extension name, version, permissions, and which files Chrome should load.
  • You load an extension into Chrome by enabling Developer Mode in chrome://extensions and selecting your extension folder.
  • Testing happens locally on your own computer before you consider publishing to the Chrome Web Store.
  • Common extensions modify web pages, add buttons to the toolbar, or run scripts in the background.

Creating your manifest.json file

Start by creating a new folder on your computer. Name it something like my-first-extension. Inside that folder, create a file called manifest.json and open it in your text editor. This file is written in JSON format, which is structured text that Chrome can read.

Here is a minimal manifest that works:

{ "manifest_version": 3, "name": "My First Extension", "version": "1.0", "description": "A simple extension that does something useful", "permissions": ["activeTab"], "action": { "default_popup": "popup.html", "default_title": "Click me" } }

The manifest_version must be 3 — this is the current standard Chrome uses. The name, version, and description are what users see. The permissions section tells Chrome what your extension is allowed to do — "activeTab" means it can access the current tab you are viewing. The action section points to your popup.html file, which is the interface users see when they click your extension icon.

Building the popup interface with HTML

In the same folder, create a file called popup.html. This is a standard HTML file that becomes the window users see when they click your extension icon. Here is a simple example:

<!DOCTYPE html> <html> <head> <title>My Extension</title> <style> body { width: 300px; padding: 10px; font-family: Arial; } button { padding: 10px; background-color: #4CAF50; color: white; border: none; cursor: pointer; } </style> </head> <body> <h1>Hello</h1> <p>Click the button below.</p> <button id="myButton">Click Me</button> <script src="popup.js"></script> </body> </html>

This creates a small window with a heading, text, and a button. The style section makes it look nicer. The script tag at the bottom loads your JavaScript file, which will handle what happens when the button is clicked.

Writing the JavaScript that makes it work

Create a file called popup.js in the same folder. This file contains the code that runs when users interact with your extension. Here is a basic example:

document.getElementById("myButton").addEventListener("click", function() { alert("Button was clicked!"); });

This code finds the button with the ID "myButton" and listens for clicks. When someone clicks it, an alert box appears with the message "Button was clicked!". You can replace this with any action you want — changing the current web page, storing data, sending information to a server, or running other code.

Most extensions do more complex work. Some modify the content of web pages, some run in the background and watch for certain events, and some add new buttons or menus to Chrome itself. The JavaScript file is where all that logic lives.

Loading your extension into Chrome

Open Chrome and go to chrome://extensions in the address bar. In the top right corner, turn on the toggle for Developer mode. You will see new buttons appear, including one that says Load unpacked.

Click Load unpacked and navigate to the folder you created with your manifest.json, popup.html, and popup.js files. Select that folder and click Open. Chrome will load your extension immediately, and you will see it appear in your extensions list with an icon.

Your extension is now active. Click its icon in the Chrome toolbar to see your popup window. If something does not work, go back to chrome://extensions, find your extension, and click the Errors button to see what went wrong. Most errors are typos in the manifest or missing files.

Testing and fixing common problems

After you load your extension, test every feature you built. Click buttons, fill in forms, and check that the results match what you expected. If your popup does not appear, check that popup.html exists in your folder and that the manifest.json file points to it correctly.

If your button does not respond to clicks, open the Chrome Developer Tools by right-clicking inside your popup and selecting Inspect. The Console tab will show any JavaScript errors. Common mistakes include misspelled element IDs, missing script tags, or JavaScript syntax errors.

After you make changes to your code, go back to chrome://extensions and click the refresh icon next to your extension. Chrome will reload your files and you can test again. This cycle — edit, refresh, test — is how you develop extensions.

Next steps: publishing or expanding your extension

Once your extension works the way you want, you can keep it private and use it only on your own computer, or you can publish it to the Chrome Web Store so other people can install it. Publishing requires a one-time developer fee and a review process where Google checks that your extension does what it claims and does not harm users.

Many developers start with a simple extension and add features over time. You might add a background script that runs even when the popup is closed, use Chrome's storage API to save user settings, or modify the content of web pages directly. The manifest.json file grows as your extension grows, but the basic structure stays the same.

Learning resources like the official Chrome Extension documentation and open-source extensions on GitHub show how other developers solved similar problems. Reading other people's code is one of the fastest ways to improve.

Frequently Asked Questions

Do I need to know how to code to build a Chrome extension?

You need basic knowledge of HTML, CSS, and JavaScript. If you have never written code before, learning the fundamentals of JavaScript will take time. Many free tutorials and courses teach these languages. Once you understand the basics, building an extension is a good next step.

Can I make an extension that works on other browsers like Firefox or Edge?

Firefox and Edge extensions use a similar structure but have some differences in how they work. The manifest format is slightly different, and some features are not available in all browsers. You can build for multiple browsers, but you usually need to adjust your code for each one.

What if I want my extension to modify web pages instead of just showing a popup?

You need to add a content script to your manifest.json. A content script is JavaScript that runs directly on web pages and can change their appearance or behavior. This requires additional permissions and a different file structure, but the basic idea is the same — write JavaScript and tell Chrome where to load it.

How do I know if my extension is slowing down Chrome?

Chrome's Task Manager shows how much memory and CPU each extension uses. Press Shift+Esc in Chrome to open it. If your extension is using a lot of resources, you can optimize your JavaScript code or reduce how often it runs. Most simple extensions have almost no impact on performance.

Can I sell my extension or make money from it?

You can charge users to install your extension through the Chrome Web Store, or you can offer it for free. Some developers offer free extensions with optional paid features. You cannot make money from ads inside extensions, but you can direct users to a website where you earn revenue.