How to Build Your First Chrome Extension: A Step-by-Step Guide for Beginners
๐ Ever wanted to build a Chrome extension but thought it was too hard? Think again! In under 30 minutes, you can create a custom extension that modifies websites, blocks distractions, or even replaces all images with cats.
In this guide, youโll learn:
โ
What makes Chrome extensions so powerful (and easy!)
โ
The 3 essential files every extension needs
โ
How to build a real extension from scratch
โ
How to publish it to the Chrome Web Store (optional)
No prior extension experience neededโjust basic HTML, CSS, and JavaScript. Letโs dive in!
Why Build a Chrome Extension?
๐ The Power of Extensions
- Automate repetitive tasks (e.g., auto-fill forms, highlight keywords)
- Modify websites (e.g., dark mode for any site)
- Integrate with APIs (e.g., ChatGPT summarizer for articles)
๐ Why Itโs Easier Than You Think
Extensions are just HTML, CSS, and JS wrapped in a special folder. If you can build a website, you can build an extension!
What You Need to Get Started
๐ File Structure of Every Chrome Extension
All extensions require:
manifest.jsonโ The "settings" file (likepackage.jsonfor Node.js).popup.html(optional) โ The UI when you click the extension icon.background.js(optional) โ Runs code in the background.content.js(optional) โ Modifies web pages directly.
my-extension/
โโโ manifest.json
โโโ popup.html
โโโ popup.css
โโโ popup.js
โโโ icons/
โโโ icon16.png
โโโ icon48.png
โโโ icon128.png
Step 1: Create the Manifest File (manifest.json)
This file tells Chrome:
- What your extension does
- What permissions it needs
- Which files to load
{
"manifest_version": 3,
"name": "My First Extension",
"version": "1.0",
"description": "A simple Chrome extension demo!",
"icons": {
"16": "icons/icon16.png",
"48": "icons/icon48.png",
"128": "icons/icon128.png"
},
"action": {
"default_popup": "popup.html"
},
"permissions": ["activeTab"]
}
๐น Key Fields:
manifest_version: Always 3 (newest standard).action: Defines what happens when you click the extension icon.permissions: Requests access to browser features (e.g.,"storage","tabs").
Step 2: Build the Popup UI (popup.html)
This is the small window that appears when you click your extensionโs icon.
<!DOCTYPE html>
<html>
<head>
<title>My Extension</title>
<link rel="stylesheet" href="popup.css">
</head>
<body>
<h1>Hello, World! ๐</h1>
<button id="changeTextBtn">Click Me</button>
<script src="popup.js"></script>
</body>
</html>
Style it with popup.css:
body {
width: 200px;
padding: 10px;
text-align: center;
font-family: Arial, sans-serif;
}
button {
background: #4285F4;
color: white;
border: none;
padding: 8px 16px;
cursor: pointer;
}
Step 3: Add Interactivity (popup.js)
Letโs make the button change the text when clicked.
document.getElementById("changeTextBtn").addEventListener("click", () => {
document.querySelector("h1").textContent = "Button Clicked! ๐";
});
Step 4: Load Your Extension in Chrome
- Go to
chrome://extensionsin Chrome. - Enable Developer mode (toggle in top-right).
- Click Load unpacked and select your extension folder.
๐ Your extension is now live! Click its icon to see the popup.
Going Further: Modify Web Pages (content.js)
Want to change websites dynamically? Use a content script.
- Update
manifest.json:
{
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["content.js"]
}
]
}
- Create
content.js:
// Replace all paragraphs with "Hello, Extension!"
document.querySelectorAll("p").forEach(p => {
p.textContent = "Hello, Extension!";
});
Reload your extension and visit any pageโyouโll see the magic!
Publishing to the Chrome Web Store (Optional)
- Zip your extension folder.
- Go to the Chrome Developer Dashboard.
- Upload, pay the $5 fee, and submit for review.
Key Takeaways
โ Chrome extensions = HTML/CSS/JS + manifest.json
โ popup.html = UI when clicking the icon
โ content.js = Modify web pages directly
โ Test locally first, then publish if needed
Your Turn: Build an Extension Today!
๐ก Try these fun ideas:
- Dark Mode For Any Site (inject CSS)
- Auto-Translate Page (using Google Translate API)
- Meme Replacer (swap all images with memes)
๐ Resources:
What will you build? Share your ideas below! ๐
Projects to explore next
Source-code projects from the KritiMyantra catalogue. Check each project's details before buying.
Flask Authentication System (Free Version) - Kritim Yantra
๐ Featuresโ Google & GitHub Authenticationโ User Registration & Loginโ Profile/Dashboard Accessโ Secure & Mi...
Flask Blog CMS with Admin Dashboard โ Python Source Code
A Flask-based blogging website with a built-in admin dashboard. Manage articles, images, categories, tags and featured p...
Laravel 12 + ReactJS Starter Kit: Add Multi-Language Support (Arabic, English, Spanish) with Blog CRUD
๐ Installation & Setup Download & Extract Get the ZIP from kritimyantra.com and extract it. Includes preconfigu...
Comments
No comments yet. Be the first to comment.
Sign in to join the discussion.