Certainly! Below is a simple web app that lets you paste a raw chat history (plain text, e.g., WhatsApp or Messenger export), and it will calculate statistics such as:
Number of messages per contact/group
Total messages
Most active contact/group
Optionally, messages per day (if timestamps are present)
Assumptions:
Each message starts with a timestamp and sender, e.g.: 2024-05-24, 10:15 - Alice: Hello!
Or for group chats: 2024-05-24, 10:15 - GroupName: Bob: Hi!
The parser is basic but can be improved for your specific format.
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Chat History Statistics</title>
<style>
body { font-family: Arial, sans-serif; margin: 2em; background: #f9f9f9; }
textarea { width: 100%; height: 200px; font-family: monospace; }
button { padding: 0.5em 1em; margin-top: 1em; }
.stats { margin-top: 2em; background: #fff; padding: 1em; border-radius: 8px; box-shadow: 0 2px 8px #0001; }
table { border-collapse: collapse; width: 100%; margin-top: 1em; }
th, td { border: 1px solid #ccc; padding: 0.5em; text-align: left; }
th { background: #eee; }
</style>
</head>
<body>
<h1>Chat History Statistics</h1>
<p>Paste your raw chat history below (e.g., WhatsApp export):</p>
<textarea id="chatInput" placeholder="Paste chat history here..."></textarea>
<br>
<button onclick="analyzeChat()">Analyze</button>
<div class="stats" id="stats" style="display:none"></div>
<script>
function analyzeChat() {
const input = document.getElementById('chatInput').value;
const lines = input.split('\n');
const messageRegex = /^(\d{4}-\d{2}-\d{2}),? ?(\d{1,2}:\d{2})? ?- (.*?): (.*)$/;
// WhatsApp: 2024-05-24, 10:15 - Alice: Hello!
// Or: 2024-05-24, 10:15 - GroupName: Bob: Hi!
let stats = {
total: 0,
perContact: {},
perDay: {},
};
for (let line of lines) {
const match = line.match(messageRegex);
if (match) {
const [_, date, time, sender, message] = match;
// If group chat, sender might be "GroupName: Bob"
let actualSender = sender;
if (sender.includes(':')) {
// GroupName: Bob
actualSender = sender.split(':').pop().trim();
}
stats.total++;
stats.perContact[actualSender] = (stats.perContact[actualSender] || 0) + 1;
if (date) {
stats.perDay[date] = (stats.perDay[date] || 0) + 1;
}
}
}
// Find most active contact
let mostActive = { name: '', count: 0 };
for (let [name, count] of Object.entries(stats.perContact)) {
if (count > mostActive.count) {
mostActive = { name, count };
}
}
// Build HTML output
let html = `<h2>Statistics</h2>
<p><strong>Total messages:</strong> ${stats.total}</p>
<p><strong>Most active contact/group:</strong> ${mostActive.name} (${mostActive.count} messages)</p>
<h3>Messages per contact/group:</h3>
<table>
<tr><th>Contact/Group</th><th>Messages</th></tr>
${Object.entries(stats.perContact).map(([name, count]) =>
`<tr><td>${name}</td><td>${count}</td></tr>`
).join('')}
</table>
<h3>Messages per day:</h3>
<table>
<tr><th>Date</th><th>Messages</th></tr>
${Object.entries(stats.perDay).map(([date, count]) =>
`<tr><td>${date}</td><td>${count}</td></tr>`
).join('')}
</table>
`;
document.getElementById('stats').innerHTML = html;
document.getElementById('stats').style.display = 'block';
}
</script>
</body>
</html>
How to use:
Copy and paste your chat export (plain text) into the textarea.
Click "Analyze".
See statistics below.
Note:
If your chat format is different, let me know and I can adjust the parser!
This is a basic example; you can expand it to include more stats (e.g., average message length, hourly activity, etc.).