Skip to content

ChatLab Standard Format Specification v0.0.1

ChatLab defines a standardized data exchange format for chat records, supporting unified import and analysis across multiple platforms.

As long as you convert your chat records to this format, they can be parsed by ChatLab and analyzed with its full capabilities.

Note

This format specification is still in early development. Some fields and structures may change in future versions.

Overview

Supported File Formats

FormatExtensionUse Case
JSON.jsonSmall to medium records (<1M messages), clear structure
JSONL.jsonlLarge-scale records (>1M messages), streaming, constant memory

Format Comparison

FeatureJSONJSONL
Memory UsageLoads entire structureLine-by-line, constant (~100MB)
File Size Limit~1GB (depends on memory)No practical limit
Append WritingRequires full rewrite✅ Direct append
Error RecoverySingle error breaks fileCan skip bad lines
Readability⭐⭐⭐ Easy to read⭐⭐ One record per line
Recommended ForSmall/medium (<1M)Large records (>1M)

Quick Start

Here's a minimal ChatLab format example with only required fields:

json
{
  "chatlab": {
    "version": "0.0.1",
    "exportedAt": 1703001600
  },
  "meta": {
    "name": "My Group Chat",
    "platform": "discord",
    "type": "group"
  },
  "members": [
    {
      "platformId": "123456",
      "accountName": "John"
    }
  ],
  "messages": [
    {
      "sender": "123456",
      "accountName": "John",
      "timestamp": 1703001600,
      "type": 0,
      "content": "Hello everyone!"
    }
  ]
}

JSON Format Details

File Header (chatlab)

FieldTypeRequiredDescription
versionstringFormat version, currently "0.0.1"
exportedAtnumberExport time (Unix timestamp in seconds)
generatorstring-Generator tool name
descriptionstring-Description

Metadata (meta)

FieldTypeRequiredDescription
namestringGroup or conversation name
platformstringPlatform: qq / wechat / discord / whatsapp etc.
typestringChat type: group / private
groupIdstring-Group ID (group chat only)
groupAvatarstring-Group avatar (Data URL format)

Members (members)

FieldTypeRequiredDescription
platformIdstringUser unique identifier
accountNamestringAccount name
groupNicknamestring-Group nickname (group only)
aliasesstring[]-User-defined aliases
avatarstring-User avatar (Data URL format)

Messages (messages)

FieldTypeRequiredDescription
senderstringSender's platformId
accountNamestringAccount name at send time
groupNicknamestring-Group nickname at send time
timestampnumberUnix timestamp in seconds
typenumberMessage type (see table below)
contentstring | nullContent (null for non-text messages)

Message Type Reference

Tip

If your chat records contain other special types that need support, please submit an issue and we'll evaluate adding them.

Basic Message Types (0-19)

ValueNameDescription
0TEXTText message
1IMAGEImage
2VOICEVoice message
3VIDEOVideo
4FILEFile
5EMOJISticker/Emoji
7LINKLink/Card
8LOCATIONLocation

Interactive Message Types (20-39)

ValueNameDescription
20RED_PACKETRed packet (gift money)
21TRANSFERMoney transfer
22POKEPoke/Nudge
23CALLVoice/Video call
24SHAREShare (music, mini-program)
25REPLYQuote reply
26FORWARDForwarded message
27CONTACTContact card

System Message Types (80+)

ValueNameDescription
80SYSTEMSystem message (join/leave/etc)
81RECALLRecalled message
99OTHEROther/Unknown

Avatar Format

Avatar fields avatar and groupAvatar use Data URL format:

data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD...

Supported image formats:

  • image/jpeg - JPEG format (recommended, smaller size)
  • image/png - PNG format
  • image/gif - GIF format
  • image/webp - WebP format

Suggestion

Compress avatars to 100×100 pixels or smaller when exporting to reduce file size.

Complete Examples

Group Chat Example (with optional fields)

json
{
  "chatlab": {
    "version": "0.0.1",
    "exportedAt": 1703001600,
    "generator": "My Converter Tool",
    "description": "2024 Tech Discussion Group Backup"
  },
  "meta": {
    "name": "Tech Discussion Group",
    "platform": "discord",
    "type": "group",
    "groupId": "38988428513",
    "groupAvatar": "data:image/jpeg;base64,/9j/4AAQSkZJRg..."
  },
  "members": [
    {
      "platformId": "abc123",
      "accountName": "John",
      "groupNickname": "Admin-John",
      "avatar": "data:image/jpeg;base64,/9j/4AAQSkZJRg..."
    },
    {
      "platformId": "def456",
      "accountName": "Alice",
      "groupNickname": "Moderator",
      "avatar": "data:image/jpeg;base64,/9j/4AAQSkZJRg..."
    }
  ],
  "messages": [
    {
      "sender": "abc123",
      "accountName": "John",
      "groupNickname": "Admin-John",
      "timestamp": 1703001600,
      "type": 0,
      "content": "Hello everyone! Welcome to the Tech Discussion Group~"
    },
    {
      "sender": "def456",
      "accountName": "Alice",
      "groupNickname": "Moderator",
      "timestamp": 1703001610,
      "type": 1,
      "content": "[Image: screenshot.jpg]"
    }
  ]
}

Private Chat Example

json
{
  "chatlab": {
    "version": "0.0.1",
    "exportedAt": 1703001600
  },
  "meta": {
    "name": "Chat with Mike",
    "platform": "whatsapp",
    "type": "private"
  },
  "members": [
    {
      "platformId": "123456789",
      "accountName": "Me",
      "avatar": "data:image/jpeg;base64,/9j/4AAQSkZJRg..."
    },
    {
      "platformId": "987654321",
      "accountName": "Mike",
      "avatar": "data:image/jpeg;base64,/9j/4AAQSkZJRg..."
    }
  ],
  "messages": [
    {
      "sender": "123456789",
      "accountName": "Me",
      "timestamp": 1703001600,
      "type": 0,
      "content": "Hey, are you there?"
    }
  ]
}

JSONL Streaming Format

JSONL (JSON Lines) format is suitable for very large chat records (>1M messages), avoiding memory overflow issues.

Features

  • One JSON object per line
  • Line type distinguished by _type field: header / member / message
  • Constant memory usage (~100MB), supports GB-sized files
  • Supports streaming writes, can append while exporting

Line Types

_typeDescriptionRequired
headerFile header with chatlab + meta✅ Must be first line
memberMember information- Optional
messageMessage record✅ At least one

Complete Example

jsonl
{"_type":"header","chatlab":{"version":"0.0.1","exportedAt":1703001600},"meta":{"name":"Tech Group","platform":"discord","type":"group"}}
{"_type":"member","platformId":"123456","accountName":"John","groupNickname":"Admin"}
{"_type":"member","platformId":"789012","accountName":"Alice"}
{"_type":"message","sender":"123456","accountName":"John","groupNickname":"Admin","timestamp":1703001600,"type":0,"content":"Hello!"}
{"_type":"message","sender":"789012","accountName":"Alice","timestamp":1703001610,"type":0,"content":"Hi there!"}
{"_type":"message","sender":"123456","accountName":"John","groupNickname":"Admin","timestamp":1703001620,"type":1,"content":"[Image]"}

Parsing Rules

  1. First line must be header: Contains chatlab version and meta information
  2. Member lines before messages: Optional, if omitted, members are collected from messages
  3. Messages in chronological order: Recommended to sort by timestamp ascending
  4. Each line is self-contained: Single line parse errors can be skipped
  5. Comment lines supported: Lines starting with # are skipped (for notes)

Note

  • Each line must be valid JSON (no line breaks within)
  • Lines separated by newline character \n

Version History

VersionDateChanges
0.0.12025-12Initial version