Parsing Instagram's connections.json Followers and Following Files

Short answer

How do you parse the followers and following files in an Instagram data download?

Request your account data in JSON format, unzip it and open the connections folder. The followers and following files list entries whose string_list_data holds the username in value and a timestamp. Load both with Python's json module, collect the usernames into sets and compare them to find accounts that do not follow back.

Step by step

  1. 1

    Download your data as JSON

    In the account settings, request a download of your information and choose JSON rather than HTML.

  2. 2

    Find the connection files

    Inside the archive, open connections/followers_and_following/. Followers may be split across several numbered files.

  3. 3

    Extract usernames

    Each entry has a string_list_data list; the username is in its value field and the follow time in timestamp.

  4. 4

    Compare the sets

    Subtract the followers set from the following set to see who does not follow you back.

Example

Python
import json
from pathlib import Path

base = Path("connections/followers_and_following")

def usernames(entries) -> set[str]:
    return {item["value"] for e in entries for item in e["string_list_data"]}

followers = set()
for f in base.glob("followers*.json"):
    followers |= usernames(json.loads(f.read_text()))

following = usernames(
    json.loads((base / "following.json").read_text())["relationships_following"]
)
print(sorted(following - followers))

Frequently Asked Questions

Why does my file have a different structure?

The export format changes from time to time. Print the top-level keys first; following is usually wrapped in a relationships_following key while followers files are plain lists.

Is this data current?

It is a snapshot from the moment the export was generated. Request a new download to compare changes over time.

Read the full guide

Working with data in Python

Try it with AlterLab

Send a URL, get the page back as HTML, markdown or JSON. Rendering, proxy rotation and retries are handled for you.

View API docs

Your first scrape.
Sixty seconds.

Up to 5,000 free requests — about 5,000 Light, 500 Protected or 250 Dynamic requests. No credit card.Just a POST request.

terminal
curl -X POST https://api.alterlab.io/v1/scrape \
-H "X-API-Key: YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com", "formats": ["markdown"]}'

No credit card required · Up to 5,000 free requests (about 5,000 Light, 500 Protected or 250 Dynamic requests) · Balance never expires