Skip to content

Guide

Exporting WhatsApp chats: the file format, privacy, parsing

By Vishnu KumarPublished 5 min read

WhatsApp's Export chat feature turns a conversation into a text file plus its media. It is the only official way to get a single chat out of the app in a readable form, and the starting point for archiving it, analysing it or turning it into a book. This guide covers how to export, what the file really contains, what to be careful about, and how to parse it if you are writing code.

How to export a chat

On Android:

  1. Open the chat (individual or group).
  2. Tap the three-dot menu, then More, then Export chat.
  3. Choose Include media to bundle photos, videos and voice notes, or Without media for text only.
  4. Pick where to send the result: a file manager, email, a cloud drive or an app that accepts it.

On iPhone:

  1. Open the chat and tap the contact's or group's name at the top.
  2. Scroll down and tap Export Chat.
  3. Choose Attach Media or Without Media, then pick where to save or share it.

The result is a ZIP file containing a text file (usually named after the chat, such as _chat.txt on iPhone or WhatsApp Chat with Asha.txt on Android) and, if you included media, every attachment as a separate file.

The limits

  • WhatsApp exports at most the latest 10,000 messages when media is included, and 40,000 without media. Older messages are simply left out, without a warning in the file.
  • Some messages never appear: messages deleted for everyone, view-once media, and anything older than the chat history on that phone.
  • Voice notes and documents are included as files when media is attached, but large chats with media can produce exports of several gigabytes, which some sharing targets refuse.

To keep a long chat complete, export it periodically, or export once without media (40,000 messages) and copy the photos you care about separately.

What the text looks like

Each message starts on a new line with a timestamp and the sender. The exact layout depends on the platform and on the phone's date and time settings. Typical Android lines:

12/03/24, 21:05 - Asha: Reached home 🙂
12/03/24, 21:06 - Ravi: Great! Call me tomorrow
about the tickets
12/03/24, 21:07 - Asha: IMG-20240312-WA0003.jpg (file attached)
12/03/24, 21:08 - Ravi: <Media omitted>
12/03/24, 21:10 - Messages and calls are end-to-end encrypted. Only people in this chat can read, listen to, or share them.

Typical iPhone lines put the timestamp in brackets, include seconds, and mark attachments differently:

[12/03/24, 9:05:33 PM] Asha: Reached home 🙂
[12/03/24, 9:06:10 PM] Ravi: Great! Call me tomorrow
about the tickets
[12/03/24, 9:07:02 PM] Asha: ‎<attached: 00000045-PHOTO-2024-03-12-21-07-02.jpg>
Things in the file that trip up readers and parsers
WhatWhy it matters
Date orderDay/month or month/day follows the phone's locale; 03/04/24 is ambiguous on its own
12- or 24-hour timeAlso follows the locale; some locales use their own AM/PM words
Multi-line messagesContinuation lines have no timestamp and belong to the previous message
System messagesEncryption notices, joins, leaves and name changes have no sender
Invisible charactersiPhone exports often include a left-to-right mark (U+200E) before attachments and some timestamps
<Media omitted>Media exported without the files
NamesSenders appear as saved in the exporting phone's contacts, or as phone numbers

Privacy: what you are holding

  • Inside WhatsApp, messages are end-to-end encrypted. The exported file is not: it is plain text that anyone holding the ZIP can read.
  • Sharing the export to email or a cloud drive puts a copy of the whole conversation on that service.
  • A chat contains other people's messages and photos. Ask before publishing or printing a group chat, and be careful with anything that identifies people who did not agree to it.
  • Delete stray copies (the Downloads folder, email drafts, chat attachments) once the export has done its job.

For the same reason, prefer tools that process the export on your device rather than uploading it. Chatcraft, which turns exports into printable books, parses the file in a web worker inside the browser tab or app, so the conversation is not sent to a server to be read.

Parsing an export in code

A robust parser treats a line as the start of a message only if it matches a timestamp pattern; every other line is appended to the previous message. A starting point that handles the two layouts above:

// Android: "12/03/24, 21:05 - Name: text"
// iPhone:  "[12/03/24, 9:05:33 PM] Name: text"
const START = /^\u200e?\[?(\d{1,2}[./-]\d{1,2}[./-]\d{2,4}),?\s+(\d{1,2}:\d{2}(?::\d{2})?(?:\s?[APap]\.?[Mm]\.?)?)\]?\s(?:-\s)?(.*)$/;

function parseChat(text) {
  const messages = [];
  for (const raw of text.split(/\r?\n/)) {
    const line = raw.replace(/\u200e/g, "");
    const m = START.exec(line);
    if (!m) {
      // A continuation of the previous message (or a blank line inside it)
      if (messages.length) messages.at(-1).text += "\n" + line;
      continue;
    }
    const [, date, time, rest] = m;
    const colon = rest.indexOf(": ");
    messages.push(colon === -1
      ? { date, time, sender: null, text: rest }               // system message
      : { date, time, sender: rest.slice(0, colon), text: rest.slice(colon + 2) });
  }
  return messages;
}
  • Do not parse dates while reading lines. Collect them first, then decide day/month order for the whole file: if any first number is above 12, it is the day.
  • A sender name can contain : , but message text often does too. Splitting at the first : is right far more often than not; a stricter parser compares against the set of participants seen so far.
  • Attachment lines refer to files in the same ZIP; match them by name to place photos where they were sent.
  • Process large exports in a worker thread or as a stream: a 40,000-message text file is several megabytes, and doing everything on the UI thread freezes the page.

What people do with an export

  • Archive a conversation before changing phones or leaving a group.
  • Search it with ordinary tools: the text file opens in any editor and grep works on it.
  • Analyse it: messages per person, busiest hours, longest streaks, most-used emoji.
  • Keep it as a book: a printed chat, with photos in place, is a common gift for anniversaries and farewells. Chatcraft lays an export out as a typeset PDF with dated chapters and a stats page, ready to print.