A quick and easy Amazon ASIN Extractor Tool and affiliate link creator (all in one).
In this tutorial, we’ll walk you through creating a simple HTML/JavaScript tool that allows you to extract ASIN codes from Amazon search results pages. This tool runs locally in your web browser, so there’s no need to host it online. It’s a quick and easy way to grab ASINs without digging through HTML code manually.
Table of Contents
What is an ASIN?
ASIN stands for Amazon Standard Identification Number. It’s a unique identifier assigned by Amazon to every product listed on their site. These 10-character alphanumeric codes are essential for sellers and marketers to manage and track their products on Amazon.
Why Extract ASINs?
If you’re working with Amazon products, you might need to collect ASINs for various purposes, such as tracking, reporting, or marketing. Manually extracting ASINs from search results can be tedious, especially if you’re dealing with multiple pages. This tool will automate that process, saving you time and effort.
Step-by-Step Guide: Building the ASIN Extractor Tool
Step 1: Create the HTML File
First, you’ll need to create an HTML file that will serve as your ASIN extractor tool. Follow these steps:
- Open a text editor of your choice (e.g., Notepad, Visual Studio Code, or Sublime Text).
- Copy and paste the following code into the text editor:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Amazon ASIN Extractor</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
}
textarea {
width: 100%;
height: 200px;
margin-bottom: 10px;
}
button {
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
}
#asin-list {
margin-top: 20px;
}
</style>
</head>
<body>
<h1>Amazon ASIN Extractor</h1>
<p>Paste the HTML source code of an Amazon search results page below and click "Extract ASINs" to get the list of ASINs.</p>
<textarea id="html-input" placeholder="Paste the HTML code here..."></textarea>
<button onclick="extractASINs()">Extract ASINs</button>
<h2>Extracted ASINs:</h2>
<textarea id="asin-list" readonly></textarea>
<script>
function extractASINs() {
const html = document.getElementById('html-input').value;
const parser = new DOMParser();
const doc = parser.parseFromString(html, 'text/html');
const asins = Array.from(doc.querySelectorAll('[data-asin]'))
.map(el => el.getAttribute('data-asin'))
.filter(asin => asin);
document.getElementById('asin-list').value = asins.join('\n');
}
</script>
</body>
</html>
- Save the file with a
.htmlextension, such asasin_extractor.html.
Step 2: Open the Tool in Your Browser
Once you’ve created and saved the HTML file, follow these steps:
- Locate the file on your computer and double-click it. This will open the file in your default web browser.
- You should see a simple interface with a text area, a button labeled “Extract ASINs,” and another text area labeled “Extracted ASINs.”
Step 3: Extract ASINs from Amazon Search Results
Now that the tool is ready, you can extract ASINs from Amazon search results:
- Go to the Amazon search results page from which you want to extract ASINs.
- Right-click on the page and select “View Page Source.” This will open the HTML source code of the page in a new tab or window.
- Copy the entire HTML code or the specific section that contains the products.
- Paste the copied HTML into the first text area in your ASIN extractor tool.
- Click the “Extract ASINs” button.
Step 4: View and Copy the Extracted ASINs
After clicking the “Extract ASINs” button, the tool will process the HTML code and extract all the ASINs. The extracted ASINs will be displayed in the second text area. You can now copy these ASINs and use them as needed.
Enhancing the Tool
This basic tool is designed to be simple and effective, but you can customize it further to meet your specific needs. Here are a few ideas:
- Export to CSV: Add a button to export the extracted ASINs to a CSV file.
- Batch Processing: Allow users to paste multiple HTML snippets at once for batch processing.
- Improved UI: Enhance the interface with additional styling or more user-friendly features.
Use
This ASIN extractor tool is a handy solution for anyone needing to pull ASIN codes from Amazon search result pages quickly. By following this tutorial, you can create a tool that runs locally in your browser, providing a fast and secure way to manage Amazon product information.
Assign Each Of The ASIN To Your Affiliate Account
Yes, you can modify the extracted ASINs to generate Amazon affiliate links automatically. Here’s how you can integrate that functionality into the existing HTML/JavaScript tool.
Adding Affiliate Link Generation
You can use your Amazon Associates ID to create affiliate links. The general format for an Amazon affiliate link using an ASIN is:
https://www.amazon.com/dp/ASIN/?tag=YOUR_ASSOCIATE_TAG
Where:
ASINis the product’s ASIN code.YOUR_ASSOCIATE_TAGis your Amazon Associates ID.
Updated HTML/JavaScript Tool
Here’s an updated version of the tool that not only extracts ASINs but also converts them into affiliate links:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Amazon ASIN Extractor and Affiliate Link Generator</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
}
textarea {
width: 100%;
height: 200px;
margin-bottom: 10px;
}
button {
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
}
#affiliate-links {
margin-top: 20px;
}
</style>
</head>
<body>
<h1>Amazon ASIN Extractor and Affiliate Link Generator</h1>
<p>Paste the HTML source code of an Amazon search results page below and click "Extract ASINs & Generate Links" to get the list of ASINs and their corresponding affiliate links.</p>
<textarea id="html-input" placeholder="Paste the HTML code here..."></textarea>
<input type="text" id="affiliate-tag" placeholder="Enter your Amazon Affiliate ID" style="width: 100%; margin-bottom: 10px;">
<button onclick="extractASINsAndGenerateLinks()">Extract ASINs & Generate Links</button>
<h2>Extracted ASINs:</h2>
<textarea id="asin-list" readonly></textarea>
<h2>Generated Affiliate Links:</h2>
<textarea id="affiliate-links" readonly></textarea>
<script>
function extractASINsAndGenerateLinks() {
const html = document.getElementById('html-input').value;
const affiliateTag = document.getElementById('affiliate-tag').value.trim();
const parser = new DOMParser();
const doc = parser.parseFromString(html, 'text/html');
const asins = Array.from(doc.querySelectorAll('[data-asin]'))
.map(el => el.getAttribute('data-asin'))
.filter(asin => asin);
// Display the extracted ASINs
document.getElementById('asin-list').value = asins.join('\n');
// Generate affiliate links
const affiliateLinks = asins.map(asin => `https://www.amazon.com/dp/${asin}/?tag=${affiliateTag}`);
document.getElementById('affiliate-links').value = affiliateLinks.join('\n');
}
</script>
</body>
</html>
How to Use the Enhanced Tool
- Open the Tool: Open the
asin_extractor.htmlfile in your browser. - Paste the HTML: Paste the HTML source code from an Amazon search results page into the first text area.
- Enter Your Affiliate ID: In the input field provided, enter your Amazon Associates ID.
- Generate Links: Click the “Extract ASINs & Generate Links” button.
- View ASINs and Links: The tool will display the extracted ASINs in one text area and the corresponding affiliate links in another.
Output Example
If the tool extracts an ASIN B08N5WRWNW and your affiliate ID is myaffiliateid, the generated link would look like this:
https://www.amazon.com/dp/B08N5WRWNW/?tag=myaffiliateid
Conclusion
This enhancement to the ASIN extractor tool allows you to instantly generate Amazon affiliate links from ASINs, making it easier to manage your affiliate marketing efforts. By following this approach, you can streamline the process of turning product listings into revenue-generating links.
We hope you find this tool helpful! If you have any questions or need further customization, feel free to reach out in the comments.
Digital Designer, blog writer and also a tech enthusiast.
He loves to write content for blogs, podcasts, design websites, logos, brochures, banners and anything that sends a message to an audience.
You can contact Daniele at the link below:



