---
title: "File format for AI agents and developers"
description: "Where MediaStash stores each post’s details inside MP4, MP3, JPEG and WebP files, the _index.jsonl format, every field, and how to read them."
url: "https://mediastash.pages.dev/ai-agents"
language: "en"
updated: "2026-11-27"
---

# File format for AI agents and developers

**Every file MediaStash saves carries a JSON record describing its post, and bulk downloads add an `_index.jsonl` file with one record per line.** The record follows the versioned schema `mediastash.instagram/1`, published as a [JSON Schema](https://mediastash.pages.dev/schema/mediastash.instagram-1.json). Nothing is uploaded: the extension has no AI inside and writes the data only into files on your computer. This page explains where the record lives in each file type, what every field means, and how to read it with common tools.

## Quick facts

| | |
| --- | --- |
| Schema id | `mediastash.instagram/1` (the `schema` field of every record) |
| JSON Schema | [/schema/mediastash.instagram-1.json](https://mediastash.pages.dev/schema/mediastash.instagram-1.json) |
| Written by | `mediastash/1.0.0` (the `tool` field: `mediastash/<extension version>`) |
| Encoding | UTF-8 JSON. Numbers are plain numbers; unknown values are `null`, never missing |
| Videos and audio | the record is the `comment` tag |
| Photos | JPEG comment (COM) segment and XMP; WebP XMP chunk |
| Bulk downloads | `_index.jsonl`: one record per post plus the names of its files |

## Where the record lives in each file

| File type | Where the JSON record is | Other tags written |
| --- | --- | --- |
| **MP4** video (`.mp4`, H.264 + AAC) | MP4 metadata (`ilst`), `©cmt` — shown as `comment` by ffprobe and exiftool | `©nam` title, `©ART` artist (`@username`), `©day` date, `desc` caption |
| **M4A** audio | same as MP4: the `comment` tag | title, artist, date, description |
| **MP3** audio | ID3v2 `COMM` frame (`comment`) | `TIT2` title, `TPE1` artist, `TDRC` date |
| **JPEG** photo or cover | a COM (comment) segment with the JSON, and an XMP packet whose `dc:description` holds the same JSON | — the image data is untouched |
| **WebP** photo | an `XMP ` chunk whose `dc:description` holds the JSON | — the image data is untouched |
| **`_index.jsonl`** | one JSON record per line | — |

Photos keep their original pixels: the record is added as extra segments or chunks, so the image is byte-for-byte the one Instagram served. Videos are always MP4 with H.264 video and AAC audio; when Instagram’s best version uses another codec, it is converted on your computer.

## File and folder names

Files are saved in Chrome’s Downloads folder:

```text
Downloads/Instagram/<account>/<account>_<YYYY-MM-DD>_<code>[_<n>][_audio|_cover|_music].<ext>
Downloads/Instagram/<account>/stories/…
Downloads/Instagram/<account>/highlights/<highlight title>/…
Downloads/Instagram/<account>/_index_<mode>_<YYYY-MM-DD-HH-MM>.jsonl
Downloads/Instagram/audio/<artist - title>_<audio id>.<mp3|m4a>
```

- `<YYYY-MM-DD>` is the day the post was published (UTC); `<code>` is the post’s short code from its URL.
- `_<n>` numbers the slides of a carousel (`_1`, `_2` …).
- `_audio` is a reel’s sound saved on its own, `_cover` a video’s cover image, `_music` the song attached to a photo post.
- With “Save as one ZIP file” the same names are used inside the ZIP, and the index is called `_index.jsonl`.

## The `_index.jsonl` file

The record inside each file is part of every download, free. Bulk downloads and their `_index.jsonl` dataset are part of [MediaStash Pro](https://mediastash.pages.dev/pricing).

Bulk downloads (“Download all” and its options) write an index next to the media: plain text, one JSON object per line ([JSON Lines](https://jsonlines.org/)), one line per post, in the order the posts were saved. Each line is the post’s record plus a `files` array with the names of the files saved for it (relative to the folder or ZIP). The per-file `item` object is not included in index lines.

```json
{"schema":"mediastash.instagram/1","platform":"instagram","url":"https://www.instagram.com/reel/DgEnau0FxTI/","shortcode":"DgEnau0FxTI","media_id":"3512345678901234567","type":"reel","author":{"username":"kai.films","full_name":"Kai Films","verified":false},"posted_at":"2026-11-24T08:12:00.000Z","caption":"First light over Fitz Roy #patagonia #hiking","hashtags":["#patagonia","#hiking"],"mentions":[],"location":{"name":"El Chaltén","city":null,"lat":null,"lng":null},"music":{"title":"Original audio","artist":"kai.films","original_audio":true},"collaborators":[],"tagged_users":[],"paid_partnership":false,"caption_edited":false,"stats":{"views":48210,"likes":3120,"comments":86,"shares":41,"reposts":null,"saves":null},"stats_hidden_by_creator":false,"stats_note":"Snapshot at captured_at. saves are not public on Instagram (always null).","captured_at":"2026-11-27T09:14:05.120Z","tool":"mediastash/1.0.0","files":["kai.films_2026-11-24_DgEnau0FxTI.mp4"]}
```

## Every field of the record

The fields below are always present in post records; unknown values are `null` (or an empty list). Profile pictures and audio-page downloads use a shorter record (see [record variants](#record-variants)).

| Field | Type | Meaning |
| --- | --- | --- |
| `schema` | string | Always `mediastash.instagram/1`. A new major version gets a new id. |
| `platform` | string | `instagram`. |
| `type` | string | `reel`, `carousel`, `post` (single photo or video), `video` (long-form video), `story`; also `profile_picture` and `audio`. |
| `url` | string \| null | Link to the post (`/p/<code>/` or `/reel/<code>/`), story, profile or audio page. |
| `shortcode` | string \| null | The code in the post’s URL. `null` for stories. |
| `media_id` | string \| null | Instagram’s numeric media id, as a string. |
| `author.username` | string \| null | Account that posted it, without `@`. |
| `author.full_name` | string \| null | Display name. |
| `author.verified` | boolean \| null | Verified badge at the time of download. |
| `posted_at` | string \| null | Publication time, ISO 8601 in UTC. |
| `caption` | string \| null | Full caption text, including hashtags and emoji. |
| `hashtags` | string[] | Unique hashtags from the caption, with `#`. |
| `mentions` | string[] | Unique `@mentions` from the caption, with `@`. |
| `location` | object \| null | `name`, `city`, `lat`, `lng` (each may be `null`). |
| `music` | object \| null | `title`, `artist`, `original_audio` (`true` for the creator’s own sound). |
| `collaborators` | string[] | Usernames of collab-post co-authors. |
| `tagged_users` | string[] | Usernames tagged in the photos or video. |
| `paid_partnership` | boolean \| null | Marked as a paid partnership. |
| `caption_edited` | boolean \| null | The caption was edited after posting. |
| `stats.views` | number \| null | Public view or play count. |
| `stats.likes` | number \| null | Like count (`null` when hidden). |
| `stats.comments` | number \| null | Comment count. |
| `stats.shares` | number \| null | Share count, when Instagram shows it. |
| `stats.reposts` | number \| null | Repost count, when Instagram shows it. |
| `stats.saves` | null | Not public on Instagram; always `null`. |
| `stats_hidden_by_creator` | boolean \| null | The creator hid like and view counts. |
| `stats_note` | string | Reminder that counts are a snapshot taken at `captured_at`. |
| `captured_at` | string | When the file was saved (ISO 8601, UTC). Counts are as of this moment. |
| `tool` | string | `mediastash/<version>` of the extension that wrote it. |
| `item` | object | **In files only.** Which part of the post this file is: `index` and `count` (slide 2 of 5), `kind` (`image`, `video`, `audio`, `cover`), `width`, `height` (pixels) and `duration` (seconds), each `null` when unknown. |
| `audio` | object | **Audio files of songs and audio pages only.** `id`, `title`, `artist`, `original_audio`, `duration_ms`. |
| `source_post` | string \| null | **Audio-page downloads only.** A reel that uses the sound. |
| `files` | string[] | **In _index.jsonl only.** Names of the files saved for this post. |

Counts are a snapshot. If you download the same post again later, the new file has newer numbers and a newer `captured_at`. Compare posts captured at about the same time, or normalise by age (for example likes per day since `posted_at`).

### Record variants

- **Profile picture** (`type: "profile_picture"`): `schema`, `platform`, `type`, `url`, `author` (with an extra `id`), `posted_at: null`, `caption: null`, `item`, `captured_at`, `tool`.
- **Audio page** (`type: "audio"`): `schema`, `platform`, `type`, `url`, `audio`, `author` (the artist), `posted_at: null`, `caption: null`, `item`, `source_post`, `captured_at`, `tool`.

Readers should ignore fields they don’t know: new optional fields can be added within version 1. Anything that would break a reader gets a new schema id.

## Read the record with command-line tools

**exiftool** reads every format:

```sh
exiftool -s3 -Comment kai.films_2026-11-24_DgEnau0FxTI.mp4 | jq .
exiftool -s3 -Comment kai.films_2026-11-23_DgGMRgQApGi_1.jpg | jq .stats
exiftool -s3 -XMP-dc:Description kai.films_2026-11-23_DgGMRgQApGi_1.webp | jq .caption
```

**ffprobe** (part of FFmpeg) reads videos and audio:

```sh
ffprobe -v quiet -show_entries format_tags=comment -of default=nw=1:nk=1 kai.films_2026-11-24_DgEnau0FxTI.mp4 | jq .
```

**jq** works directly on the index:

```sh
# Top 10 posts by views
jq -s 'sort_by(-(.stats.views // 0)) | .[:10] | .[] | {url, views: .stats.views, caption}' _index_*.jsonl

# Export a spreadsheet
jq -r '[.posted_at, .type, .stats.views, .stats.likes, .stats.comments, .url] | @csv' _index_*.jsonl > posts.csv

# Most used hashtags
jq -r '.hashtags[]' _index_*.jsonl | sort | uniq -c | sort -rn | head
```

## Read the record with Python

Standard library only, plus `ffprobe` for videos and Pillow for photos:

```python
import html, json, re, subprocess, sys
from pathlib import Path

def from_xmp(xmp: bytes) -> dict:
    match = re.search(rb'<rdf:li xml:lang="x-default">(.*?)</rdf:li>', xmp, re.S)
    return json.loads(html.unescape(match.group(1).decode("utf-8")))

def read_record(path: Path) -> dict | None:
    suffix = path.suffix.lower()
    if suffix in (".mp4", ".m4a", ".mp3"):
        out = subprocess.run(
            ["ffprobe", "-v", "quiet", "-show_entries", "format_tags=comment",
             "-of", "default=nw=1:nk=1", str(path)],
            capture_output=True, text=True, check=True).stdout.strip()
        return json.loads(out) if out else None
    if suffix in (".jpg", ".jpeg", ".webp"):
        from PIL import Image  # pip install pillow
        with Image.open(path) as img:
            if "comment" in img.info:  # JPEG COM segment
                return json.loads(img.info["comment"])
            xmp = img.info.get("xmp")  # WebP XMP chunk
            return from_xmp(xmp) if xmp else None
    return None

for file in sorted(Path(sys.argv[1]).rglob("*")):
    record = read_record(file) if file.is_file() else None
    if record:
        print(file.name, record["type"], record["stats"]["views"] if "stats" in record else "")
```

To load an index: `[json.loads(line) for line in open("_index_posts_2026-11-27-09-14.jsonl", encoding="utf-8")]`.

## How an AI agent can analyse a folder of downloads

1. **Start with the index.** If the folder has `_index_*.jsonl` (or `_index.jsonl` in a ZIP), read it first: one line per post, with all counts and the file names. No need to open the media.
2. **Otherwise read the files.** For each `.mp4`, `.m4a` and `.mp3`, read the `comment` tag; for `.jpg`, the COM segment; for `.webp`, the XMP `dc:description`. Group files by `url` (or `shortcode`): carousel slides and covers share the same post record and differ only in `item`.
3. **Check the schema.** Accept records whose `schema` is `mediastash.instagram/1`; validate against the [JSON Schema](https://mediastash.pages.dev/schema/mediastash.instagram-1.json) if you need certainty.
4. **Treat counts as snapshots.** Use `captured_at` and `posted_at` to compare fairly — for example views per day since posting. `null` means unknown or hidden, not zero.
5. **Use the text fields.** `caption`, `hashtags`, `mentions`, `music` and `location` answer “what is this about?”; `type` separates reels from photos and stories.
6. **Cite the source.** Every record has the post’s `url`, so answers can link back to Instagram.

Example questions an agent can answer from the index alone: which reels got the most views, which hashtags appear in the top posts, how engagement changed month by month, which songs a creator uses most.

> **Respect creators**
>
> The data describes public posts by real people. Use it for your own analysis, respect creators’ rights and privacy, and follow Instagram’s terms and the law where you live.

## Privacy

MediaStash writes these records on your computer, from information Instagram already shows you in your browser. It has no AI inside, no servers and no analytics, and it uploads nothing. Whether a file is ever read by an AI tool is entirely your choice. See the [privacy policy](https://mediastash.pages.dev/privacy).
