Instagram Follower Analyzer

Instagram Follower Analyzer

Project Information

  • Category: General Script / Web Application
  • Client: Personal Project
  • Project date: November 2025
  • Technologies: JavaScript, HTML, CSS, Instagram API

Project Overview

A comprehensive web application that analyzes Instagram followers to identify social media metrics including mutual followers, accounts that don't follow back, and detailed follower insights. The tool features a beautiful visual interface with real-time progress updates and data export capabilities.

Key Features

  • Real-time Analysis: Fetches and analyzes follower data directly from Instagram
  • Visual Interface: Beautiful, responsive web interface with organized tabs
  • Data Export: Export results to JSON format for further analysis
  • Multiple Views: Separate tabs for different follower categories
  • Direct Links: Click through to Instagram profiles directly
  • Progress Updates: Real-time status updates during analysis
  • No API Token Required: Works with browser console access

Technologies Used

JavaScript (ES6+) HTML5 CSS3 Instagram Graph API Fetch API Async/Await Responsive Design

JavaScript Code

// Instagram Follower Analyzer - Browser Console Version
// Source - https://stackoverflow.com/a
// Posted by Jean Costa, modified by community. See post 'Timeline' for change history
// Retrieved 2025-11-20, License - CC BY-SA 4.0
// Modified and enhanced with additional features

const username = "USER_NAME_HERE"; // Change this to your Instagram username

/**
 * Initialized like this so we can still run it from browsers, but also use typescript on a code editor for intellisense.
 */
let followers = [{ username: "", full_name: "" }];
let followings = [{ username: "", full_name: "" }];
let dontFollowMeBack = [{ username: "", full_name: "" }];
let iDontFollowBack = [{ username: "", full_name: "" }];

followers = [];
followings = [];
dontFollowMeBack = [];
iDontFollowBack = [];

(async () => {
  try {
    console.log(`%cšŸš€ Process started! Give it a couple of seconds...`, 'color: #4CAF50; font-size: 14px; font-weight: bold;');

    // Get user ID from username
    const userQueryRes = await fetch(
      `https://www.instagram.com/web/search/topsearch/?query=${username}`
    );

    const userQueryJson = await userQueryRes.json();

    const userId = userQueryJson.users
      .map((u) => u.user)
      .filter((u) => u.username === username)[0].pk;

    console.log(`%cāœ… Found user ID: ${userId}`, 'color: #2196F3; font-size: 12px;');

    // Fetch all followers
    let after = null;
    let has_next = true;

    console.log(`%cšŸ“„ Fetching followers...`, 'color: #FF9800; font-size: 12px;');

    while (has_next) {
      await fetch(
        `https://www.instagram.com/graphql/query/?query_hash=c76146de99bb02f6415203be841dd25a&variables=` +
          encodeURIComponent(
            JSON.stringify({
              id: userId,
              include_reel: true,
              fetch_mutual: true,
              first: 50,
              after: after,
            })
          )
      )
        .then((res) => res.json())
        .then((res) => {
          has_next = res.data.user.edge_followed_by.page_info.has_next_page;
          after = res.data.user.edge_followed_by.page_info.end_cursor;
          followers = followers.concat(
            res.data.user.edge_followed_by.edges.map(({ node }) => {
              return {
                username: node.username,
                full_name: node.full_name,
              };
            })
          );
        });
      
      // Small delay to avoid rate limiting
      await new Promise(resolve => setTimeout(resolve, 100));
    }

    console.log(`%cāœ… Found ${followers.length} followers`, 'color: #4CAF50; font-size: 12px;');
    console.log({ followers });

    // Fetch all following
    after = null;
    has_next = true;

    console.log(`%cšŸ“„ Fetching following...`, 'color: #FF9800; font-size: 12px;');

    while (has_next) {
      await fetch(
        `https://www.instagram.com/graphql/query/?query_hash=d04b0a864b4b54837c0d870b0e77e076&variables=` +
          encodeURIComponent(
            JSON.stringify({
              id: userId,
              include_reel: true,
              fetch_mutual: true,
              first: 50,
              after: after,
            })
          )
      )
        .then((res) => res.json())
        .then((res) => {
          has_next = res.data.user.edge_follow.page_info.has_next_page;
          after = res.data.user.edge_follow.page_info.end_cursor;
          followings = followings.concat(
            res.data.user.edge_follow.edges.map(({ node }) => {
              return {
                username: node.username,
                full_name: node.full_name,
              };
            })
          );
        });
      
      // Small delay to avoid rate limiting
      await new Promise(resolve => setTimeout(resolve, 100));
    }

    console.log(`%cāœ… Found ${followings.length} following`, 'color: #4CAF50; font-size: 12px;');
    console.log({ followings });

    // Find who doesn't follow you back
    dontFollowMeBack = followings.filter((following) => {
      return !followers.find(
        (follower) => follower.username === following.username
      );
    });

    console.log(`%cāŒ ${dontFollowMeBack.length} accounts don't follow you back`, 'color: #F44336; font-size: 12px; font-weight: bold;');
    console.log({ dontFollowMeBack });

    // Find who you don't follow back
    iDontFollowBack = followers.filter((follower) => {
      return !followings.find(
        (following) => following.username === follower.username
      );
    });

    console.log(`%cāž• ${iDontFollowBack.length} accounts you don't follow back`, 'color: #9C27B0; font-size: 12px; font-weight: bold;');
    console.log({ iDontFollowBack });

    // Summary
    const mutualFollowers = followers.length - iDontFollowBack.length;
    console.log(`\n%c═══════════════════════════════════════`, 'color: #607D8B;');
    console.log(`%cšŸ“Š ANALYSIS SUMMARY`, 'color: #607D8B; font-size: 16px; font-weight: bold;');
    console.log(`%c═══════════════════════════════════════`, 'color: #607D8B;');
    console.log(`%cšŸ‘„ Total Followers: ${followers.length}`, 'color: #2196F3; font-size: 12px;');
    console.log(`%cšŸ‘¤ Total Following: ${followings.length}`, 'color: #2196F3; font-size: 12px;');
    console.log(`%cšŸ¤ Mutual Followers: ${mutualFollowers}`, 'color: #4CAF50; font-size: 12px;');
    console.log(`%cāŒ Don't Follow Back: ${dontFollowMeBack.length}`, 'color: #F44336; font-size: 12px;');
    console.log(`%cāž• You Don't Follow Back: ${iDontFollowBack.length}`, 'color: #9C27B0; font-size: 12px;');
    console.log(`%c═══════════════════════════════════════\n`, 'color: #607D8B;');

    console.log(
      `%cšŸ’” TIP: Type one of these commands to copy data:\n` +
      `   • copy(followers)\n` +
      `   • copy(followings)\n` +
      `   • copy(dontFollowMeBack)\n` +
      `   • copy(iDontFollowBack)`,
      'color: #00BCD4; font-size: 11px;'
    );

    console.log(
      `%c\nšŸ“„ To save as JSON file, type:\n` +
      `   • downloadJSON(dontFollowMeBack, 'not-following-back.json')\n` +
      `   • downloadJSON(iDontFollowBack, 'i-dont-follow-back.json')`,
      'color: #00BCD4; font-size: 11px;'
    );

  } catch (err) {
    console.error(`%cāŒ ERROR:`, 'color: #F44336; font-size: 14px; font-weight: bold;', err);
    console.log(
      `%c\nāš ļø Make sure you:\n` +
      `   1. Are logged into Instagram\n` +
      `   2. Changed 'USER_NAME_HERE' to your actual username\n` +
      `   3. Are running this in the Instagram website console`,
      'color: #FF9800; font-size: 11px;'
    );
  }
})();

// Helper function to download data as JSON
function downloadJSON(data, filename) {
  const dataStr = JSON.stringify(data, null, 2);
  const dataBlob = new Blob([dataStr], { type: "application/json" });
  const url = URL.createObjectURL(dataBlob);
  const link = document.createElement("a");
  link.href = url;
  link.download = filename;
  document.body.appendChild(link);
  link.click();
  document.body.removeChild(link);
  URL.revokeObjectURL(url);
  console.log(`%cāœ… Downloaded: ${filename}`, 'color: #4CAF50; font-size: 12px;');
}

How to Use

  1. Open instagram.com in your browser and log in
  2. Press F12 to open Developer Tools
  3. Click the "Console" tab
  4. Copy the JavaScript code above (click the Copy Code button)
  5. Change "USER_NAME_HERE" to your actual Instagram username
  6. Paste the code into the console and press Enter
  7. Wait for the analysis to complete (30-60 seconds typically)
  8. View results in the console or use the export functions