Wrapped Year

Wrapped Year’s local parser

Inspect and download the code that reads your export and builds your report.

The parser runs in your browser. It reads ChatGPT conversation JSON files, extracts conversation data from ZIP files, merges records, and calculates the statistics for each report year.

Inspect the parser

Open View Source on this page to see the code below in the HTML. You can also open the browser’s developer tools on the report page, find the wrapped-report script in Sources, and search for “Wrapped Year local parser”. The parser below is the same source used by the report.

/* Wrapped Year local parser, rules version 3. Effective 2026-11-30. */
const ALL_TIME = 'all-time';
const STOP_WORDS = new Set((
  'about above across actually after again against all also always another any are around ask asking back because become been before being below between both but can change chat chatbot chatgpt conversation could did does doing done down during each either else enough even every few figure first for found from further get getting give given going good got great had has have having help here how into instead itself just keep kind know last later least less let like look lot made make many may mean might more most much must need needs new next now off often once one only onto open other our out over own part people perhaps please pls point quite rather really right said same say second see seem shall should simple since some someone something still such sure take tell than thank thanks that the their them then there these they thing this those though through thx time too toward try two under until untitled upon use used uses using very want was way well were what when where whether which while who why will with within without work would yet you your'
).split(' '));
const MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
const DAY_MS = 86400000;

function decodeChatGPTExport(text) {
  const data = JSON.parse(text.replace(/^\uFEFF/, ''));
  const conversations = Array.isArray(data) ? data : data && data.conversations;
  if (!Array.isArray(conversations) || (conversations.length && !conversations.some(item => item?.mapping && typeof item.mapping === 'object'))) {
    throw new Error('Expected ChatGPT conversation data.');
  }
  return conversations;
}

async function readChatGPTFile(file, zipReader) {
  if (!/\.zip$/i.test(file.name)) {
    return { conversations: decodeChatGPTExport(await file.text()), parts: 1, errors: [] };
  }
  if (!zipReader) throw new Error('ZIP support is unavailable. Extract the conversation JSON files and select them directly.');
  const zip = await zipReader.loadAsync(file);
  const names = Object.keys(zip.files).filter(name =>
    /(?:^|\/)conversations(?:[-_]?\d+)?\.json$/i.test(name) && !zip.files[name].dir
  ).sort();
  if (!names.length) throw new Error('No ChatGPT conversation JSON files were found inside this ZIP.');

  const result = { conversations: [], parts: 0, errors: [] };
  for (const name of names) {
    try {
      const rows = decodeChatGPTExport(await zip.file(name).async('string'));
      for (const row of rows) result.conversations.push(row);
      result.parts++;
    } catch {
      result.errors.push(name + ': could not read this ChatGPT conversation JSON.');
    }
  }
  return result;
}

function topicWords(text) {
  return (String(text || '').toLowerCase().match(/[\p{L}\p{N}]+/gu) || [])
    .filter(word => word.length >= 3 && word.length <= 48 && /\p{L}/u.test(word) && !STOP_WORDS.has(word));
}

function mergeConversations(conversations) {
  const groups = new Map();
  for (const item of conversations) {
    if (!item?.mapping || typeof item.mapping !== 'object') continue;
    const key = item.id || item.conversation_id || Symbol();
    if (!groups.has(key)) groups.set(key, { title: '', mappings: [] });
    const group = groups.get(key);
    if (!group.title && topicWords(item.title).length) group.title = item.title;
    group.mappings.push(item.mapping);
  }
  return groups.values();
}

function newPeriod() {
  return {
    messages: 0, convCount: 0, words: 0, polite: 0, night: 0, longest: 0, timed: 0,
    hours: Array(24).fill(0), days: Array(7).fill(0),
    topics: new Map(), openers: new Map(), months: new Map(), weeks: new Map(), activeDays: new Set()
  };
}

function increment(map, key) {
  map.set(key, (map.get(key) || 0) + 1);
}

function countMessage(period, wordCount, polite, opener, date) {
  period.messages++;
  period.words += wordCount;
  period.polite += polite;
  period.longest = Math.max(period.longest, wordCount);
  if (opener) increment(period.openers, opener);
  if (!date) return;
  const hour = date.getHours();
  const weekday = date.getDay();
  period.timed++;
  period.hours[hour]++;
  period.days[weekday]++;
  if (hour < 6) period.night++;
  increment(period.months, date.getFullYear() * 12 + date.getMonth());
  const day = Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()) / DAY_MS;
  period.activeDays.add(day);
  increment(period.weeks, day - (weekday + 6) % 7);
}

function countDocument(period, title, body) {
  period.convCount++;
  for (const word of new Set([...title, ...body.keys()])) {
    const term = period.topics.get(word) || { docs: 0, weight: 0 };
    term.docs++;
    term.weight += (title.has(word) ? 3 : 0) + Math.log1p(body.get(word) || 0);
    period.topics.set(word, term);
  }
}

function collectPeriods(conversations) {
  const all = newPeriod();
  const years = new Map();
  const seen = new Set();
  for (const conversation of mergeConversations(conversations)) {
    const title = new Set(topicWords(conversation.title));
    const allTerms = new Map();
    const yearlyTerms = new Map();
    let counted = false;
    for (const mapping of conversation.mappings) {
      for (const node of Object.values(mapping)) {
        const message = node?.message;
        if (message?.author?.role !== 'user' || (message.id && seen.has(message.id))) continue;
        const parts = message.content?.parts;
        if (!Array.isArray(parts)) continue;
        const text = parts.filter(part => typeof part === 'string').join(' ').trim();
        if (!text) continue;
        if (message.id) seen.add(message.id);
        counted = true;

        let date = null;
        if (typeof message.create_time === 'number' && message.create_time > 0) {
          const value = new Date(message.create_time * 1000);
          if (Number.isFinite(value.getTime()) && value.getFullYear() <= 9999) date = value;
        }
        const low = text.toLowerCase();
        const wordCount = text.split(/\s+/).length;
        const polite = (low.match(/\b(please|pls|thank you|thanks|thx)\b/g) || []).length;
        const opener = low.split(/\s+/).slice(0, 2).join(' ').replace(/[.,!?:;"'\u2019]+$/g, '');
        const terms = topicWords(low);
        countMessage(all, wordCount, polite, opener, date);
        for (const word of terms) increment(allTerms, word);
        if (!date) continue;
        const year = String(date.getFullYear());
        if (!years.has(year)) years.set(year, newPeriod());
        if (!yearlyTerms.has(year)) yearlyTerms.set(year, new Map());
        countMessage(years.get(year), wordCount, polite, opener, date);
        for (const word of terms) increment(yearlyTerms.get(year), word);
      }
    }
    if (counted) countDocument(all, title, allTerms);
    for (const [year, body] of yearlyTerms) countDocument(years.get(year), title, body);
  }
  return { all, years };
}

function trendLabel(key, weekly) {
  if (!weekly) return MONTHS[key % 12] + ' ' + Math.floor(key / 12);
  const date = new Date(key * DAY_MS);
  return MONTHS[date.getUTCMonth()] + ' ' + date.getUTCDate() + ', ' + date.getUTCFullYear();
}

function getTrend(period) {
  const weekly = period.months.size < 2;
  const buckets = weekly ? period.weeks : period.months;
  if (buckets.size < 2) return null;
  const keys = [...buckets.keys()].sort((a, b) => a - b);
  const first = keys[0];
  const last = keys[keys.length - 1];
  const step = weekly ? 7 : 1;
  const full = (last - first) / step + 1;
  const points = full <= 120 ? Array.from({ length: full }, (_, i) => first + i * step) : keys;
  let peak = first;
  for (const key of keys) if (buckets.get(key) > buckets.get(peak)) peak = key;
  return {
    weekly, peak: buckets.get(peak), peakKey: peak, peakLabel: trendLabel(peak, weekly),
    points: points.map(key => ({
      key, label: trendLabel(key, weekly), value: buckets.get(key) || 0, position: (key - first) / (last - first)
    }))
  };
}

function getArchetype(period, topTopic) {
  const avg = period.words / period.messages;
  if (period.messages < 12) return 'First Steps';
  if (period.timed >= 10 && period.night / period.timed >= 0.35) return 'Night Owl';
  if (avg >= 45) return 'Long-Form Thinker';
  if (period.convCount >= 3 && topTopic && topTopic.docs / period.convCount >= 0.60) return 'Focused Explorer';
  if (avg <= 12) return 'Quick Asker';
  return 'Everyday Explorer';
}

function getActivityHighlights(period) {
  const days = [...period.activeDays].sort((a, b) => a - b);
  let streak = 0;
  let longestStreak = 0;
  let previous;
  for (const day of days) {
    streak = day === previous + 1 ? streak + 1 : 1;
    longestStreak = Math.max(streak, longestStreak);
    previous = day;
  }

  let peakMonth = null;
  for (const [key, count] of period.months) {
    if (!peakMonth || count > peakMonth.count || (count === peakMonth.count && key < peakMonth.key)) {
      peakMonth = { key, count, label: trendLabel(key, false) };
    }
  }
  return { activeDays: days.length, longestStreak, peakMonth };
}

function summarize(period, range) {
  const topics = [...period.topics].map(([word, term]) => ({
    word, docs: term.docs, score: term.weight * (1 + Math.log((1 + period.convCount) / (1 + term.docs)))
  })).sort((a, b) => b.score - a.score || b.docs - a.docs || (a.word < b.word ? -1 : 1)).slice(0, 5);
  const topOpeners = [...period.openers].sort((a, b) => b[1] - a[1]).slice(0, 5);
  return {
    range, label: range === ALL_TIME ? 'All time' : range,
    messages: period.messages, words: period.words, polite: period.polite, night: period.night,
    longest: period.longest, avg: Math.round(period.words / period.messages), convCount: period.convCount,
    hours: period.hours, hoursMax: Math.max(1, ...period.hours),
    peak: period.timed ? period.hours.indexOf(Math.max(...period.hours)) : null,
    dayPeak: period.timed ? period.days.indexOf(Math.max(...period.days)) : null,
    topics, topOpeners, trend: getTrend(period), archetype: getArchetype(period, topics[0]),
    ...getActivityHighlights(period)
  };
}

Check what your browser sends

Load the report page and clear the Network log in DevTools after it finishes loading. Run the demo or choose a local export. Inspect any new requests for exported file data. To repeat the test offline, disconnect after the page loads.

Read how we count it for the topic, trend and archetype rules.

Try the parser with sample data

Open Wrapped Year and choose Try Demo to run the same code without selecting any files.

Make your ChatGPT Wrapped