Blog / Build with AI /
Building a Chrome extension with AI: the complete beginner’s guide
A Chrome extension is one of the friendliest first software projects you can build. It’s small. It runs in a browser you already use. It can fix an annoyance you have every day. And with an AI assistant doing the heavy typing, you can get a working one in an afternoon, even if you’ve never built one.
That doesn’t mean it’s magic. The AI will happily write code that looks right and doesn’t work. The skill is knowing what an extension is made of, so you can describe what you want, test what you get and tell when something’s off.
This guide covers exactly that: the pieces, a small working example, how to talk to the AI, how to test it, what breaks and how to publish. I built TabHue, a Chrome extension, with AI, and that story goes deeper on one real product. Here we start from zero.
Key takeaways
- An extension is a folder of ordinary web files plus one
manifest.jsonthat describes it. - Start with one small job. A tiny extension that works beats a clever one that doesn’t.
- Ask the AI to explain its code and keep a working version at every step.
- You test locally in Chrome in under a minute, without publishing anything.
- Permissions are the part that most affects trust, review and users, so ask for as few as you can.
What a Chrome extension actually is
It’s a small web app that lives inside the browser. It’s built from HTML, CSS and JavaScript, the same things as a website. What’s different is that it can use special browser features, like reading the current tab, saving data or adding a button to the toolbar.
Think of it like a plug-in for your browser’s kitchen. The browser is the kitchen, and your extension is a new gadget that can use some of the appliances, as long as the browser says yes.
The parts, in plain words
Most extensions are made from a few of these:
| Part | What it does | Do you need it? |
|---|---|---|
manifest.json |
The ID card: name, version, what it’s allowed to do | Always |
| Popup (HTML, CSS, JS) | The small window that opens when you click the toolbar icon | Often |
| Content script | JavaScript that runs inside the web pages you visit | When you need to read or change a page |
| Background service worker | A script that runs in the background and reacts to events | When you need to react to browser events |
| Options page | A settings screen | Optional |
| Icons | Toolbar and store pictures | For the store |
You don’t need all of them. The example below uses only a manifest and a popup.
Step 1: pick one small job
The most common mistake in a first extension is trying to do five things. Choose something you’d use yourself, that fits in one sentence.
Good first ideas:
- “Show the word count of the page I’m reading.”
- “Copy the page title and URL as a tidy link.”
- “Highlight every external link on a page.”
- “Add a note to the current tab and show it later.”
For the walkthrough, we’ll build the first one: a toolbar button that tells you how many words are on the page. It’s small, it’s useful if you write or edit content, and it teaches you the permission system.
Step 2: tell the AI what you want
The way you ask is the biggest factor in what you get. Describe the finished behaviour in plain words, and name the version of the platform. For example:
I want to build a Chrome extension using Manifest V3. When I click its toolbar icon, a small popup opens with a button labelled “Count words”. When I click it, it counts the words on the current tab and shows the number in the popup. Use the fewest permissions possible. Give me every file separately with its name, and explain each one in plain English as if I’m new to extensions.
Why this works:
- “Manifest V3” stops the assistant from writing outdated patterns. Manifest V3 is the current extension format.
- “Fewest permissions” nudges it away from asking for access to everything.
- “Every file separately” makes it easy to copy and save.
- “Explain as if I’m new” gives you something to learn from, and a way to spot nonsense.
Step 3: the files
Here’s a working version. Make a folder called page-word-count and create three files inside it.
manifest.json
{
"manifest_version": 3,
"name": "Page Word Count",
"version": "1.0.0",
"description": "Shows the word count of the page you are reading.",
"action": {
"default_popup": "popup.html",
"default_title": "Count words"
},
"permissions": ["activeTab", "scripting"]
}
popup.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
body { font-family: sans-serif; width: 200px; padding: 12px; }
button { width: 100%; padding: 8px; }
#out { margin-top: 10px; font-size: 18px; }
</style>
</head>
<body>
<button id="count">Count words</button>
<div id="out"></div>
<script src="popup.js"></script>
</body>
</html>
popup.js
document.getElementById("count").addEventListener("click", async () => {
const [tab] = await chrome.tabs.query({ active: true, currentWindow: true });
const [result] = await chrome.scripting.executeScript({
target: { tabId: tab.id },
func: () => document.body.innerText.trim().split(/\s+/).length
});
document.getElementById("out").textContent = result.result + " words";
});
What’s going on, line by line in spirit:
- The manifest says: this is a Manifest V3 extension called Page Word Count, with a popup, allowed to run a script on the tab you’ve just clicked in (
activeTabplusscripting). - The popup is a plain web page with a button.
- When you click the button, the script finds the active tab, runs a small function inside that page that counts the words in the page’s visible text, and writes the result back into the popup.
The permission activeTab is important: it gives access to the current tab only when you click the extension, rather than to every site you visit. That’s a much easier thing to explain to users than “can read all your data on all websites”.
Step 4: load it in Chrome
You don’t need to publish anything to try it.
- Open
chrome://extensionsin Chrome. - Switch on Developer mode (top right).
- Click Load unpacked and choose your
page-word-countfolder. - The extension appears. Pin it from the puzzle-piece menu so the icon is visible.
- Open any article, click the icon, click the button.
If it works, you’ll see a number. If not, don’t panic. Go to the next step.
Step 5: debug without being a developer
When something breaks, Chrome tells you where to look:
- On
chrome://extensions, a red Errors button appears on your extension’s card. Click it. - Right-click the popup and choose Inspect to open developer tools for the popup itself, then read the Console tab.
- If you changed a file, click the reload icon on the extension’s card. Chrome doesn’t always pick up changes by itself.
Then use the AI properly. Don’t write “it doesn’t work”. Paste the exact error message and the relevant file, and say what you expected to happen:
I get this error in the popup console: [paste the error]. Here is popup.js: [paste]. I expected the popup to show the word count. What’s wrong, and why?
A concrete error plus the code gets a useful answer. “It’s broken” gets a guess.
Note that the example won’t work on special browser pages such as chrome://extensions, or on the Chrome Web Store itself, because extensions are not allowed to run scripts there. That’s a rule, not a bug.
Step 6: improve it, one change at a time
Once the basic version works, add small things:
- Show reading time as well as words.
- Count only the selected text.
- Add an icon.
- Remember the last count.
Rules that save you pain:
- One change per request. If you ask for five and something breaks, you can’t tell which.
- Save a copy of the working folder before each change. Your AI assistant can’t undo what it breaks, and you’ll thank yourself later.
- Ask for the full updated file, not a fragment that says “add this somewhere”.
- Ask it to explain the change before you accept it.
I described a similar discipline for building with these tools in the AI coding workflow I use now, and the beginner’s view in building with AI when you are not a developer: my honest take.
What usually goes wrong
Common problems, and how to deal with them:
Old code patterns
AI tools sometimes write for the older extension format. If you see a manifest with "manifest_version": 2, or code that relies on a persistent background page, tell the assistant to rewrite it for Manifest V3. Chrome moved extensions to V3, and V2 is on its way out.
Too many permissions
Assistants love to request broad access “just in case”, such as access to all websites. Ask: “Which of these permissions can I remove, and what would stop working?” Fewer permissions means a smaller trust ask for users and an easier time in review.
Code that runs in the wrong place
Extensions have separate worlds: the popup, the background worker and the web page. A script that reads the page must run in the page (a content script or executeScript), not in the popup. If the AI mixes these up, your code runs but finds nothing.
Things that aren’t saved
If you want an extension to remember something, it needs storage (chrome.storage), which also needs the right permission. Variables disappear when the popup closes. If you’re keeping data on the device only, say so in the prompt.
Invented functions
Sometimes the assistant uses a browser function that doesn’t exist. If the console says something is “not a function”, ask the assistant to check it against the official Chrome extension documentation and suggest the correct call.
Security
Never paste secrets, such as API keys, into extension code that people will download. Anything inside the extension can be read. If you need a secret, it belongs on a server. I’ve also written about reading AI-generated code with a suspicious eye in AI and security: what to check before you ship.
Step 7: prepare to publish (if you want to)
You don’t have to publish. An extension for yourself or a small team can stay local. If you do want others to use it:
- Register as a Chrome Web Store developer. There’s a small one-time registration fee.
- Prepare assets: icons in the sizes the store asks for, screenshots and a clear description.
- Write a privacy statement. Say what data the extension reads, whether it leaves the device and why you need each permission. Honest and short beats clever.
- Zip the folder with the manifest at the top level, not inside a sub-folder.
- Upload it in the developer dashboard, fill in the listing and submit for review.
Review can take a while, and it can come back with questions, especially about permissions. That’s why you asked for as few as you could.
What makes a good first extension
After the word counter, what next? Look for problems where:
- you repeat the same small action every day,
- no existing tool fits how you work,
- the result is easy to check,
- the first version fits on one screen.
That’s a better source of ideas than trying to invent a product. Many useful extensions begin as a person scratching their own itch.
A note for people who run websites
If you work on websites, extensions are especially handy: you can check headings, show meta titles, highlight nofollow links, copy structured data or list images without alt text, all while looking at the live page. These are small jobs where a focused tool beats opening a heavy platform. It’s also a good way to learn how pages are really built, because you’re reading the page’s structure as you go.
FAQ
Do I need to know how to code?
Not to begin. You do need patience, and a willingness to read what the AI gives you and to test it. The more you learn about HTML and JavaScript, the faster you’ll spot problems.
Which AI tool should I use?
Any capable coding assistant can do this. What matters more than the tool is how clearly you describe the task, and that you test every change.
Is Manifest V3 hard?
For a beginner, no. The main difference from older tutorials is how background code runs and what permissions you ask for. If you tell your assistant “Manifest V3”, it should follow the current rules.
Can I charge for an extension?
Yes, but it takes more than code: a clear reason to pay, a way to collect payment and a plan for support. Free and useful comes first.
Can the extension work in other browsers?
Many browsers built on the same engine can load Chrome extensions, often with small changes. Test in each one you care about.
Your next step
Make the word counter today. Then change one thing: add reading time, or make it count only selected text. When you can describe a change, get it, test it and understand why it works, you’ve learned the whole loop. Everything else is the same loop with a bigger idea.
Related reading
- Your first Chrome extension: a ten-line example
- Building a reading mode extension with AI
- Building a page notes extension with AI
What’s the one thing you do in your browser every day that you wish was a single click?