Skip to content

ChatLab Standard Format Specification v0.0.1

ChatLab defines a standard chat record data exchange format to support unified import and analysis of multi-platform data.

As long as you convert your chat records to this format, ChatLab can parse and analyze them.

📥 Click here to download this specification (.md)

Notice

This format specification is still in its early development stage. Some fields and structures may be adjusted in future versions.

Overview

Supported File Formats

FormatExtensionUse Case
JSON.jsonSmall to medium records (<1 million), clear structure
JSONL.jsonlVery large records (>1 million), streaming, constant memory

Format Comparison

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

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": "qq",
    "type": "group"
  },
  "members": [
    {
      "platformId": "123456",
      "accountName": "John"
    }
  ],
  "messages": [
    {
      "sender": "123456",
      "accountName": "John",
      "timestamp": 1703001600,
      "type": 0,
      "content": "Hello everyone!"
    }
  ]
}

JSON Format Detailed Specification

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 name or conversation name
platformstringPlatform identifier: 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 when sending
groupNicknamestring-Group nickname when sending
timestampnumberUnix timestamp in seconds
typenumberMessage type (see table below)
contentstring | nullMessage content (null for non-text)

Message Type Reference

Tip

If you have other special types in your chat records that need support, please submit an issue explaining your situation. We'll evaluate whether to add them to the standard message types.

Basic Message Types (0-19)

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

Interactive Message Types (20-39)

ValueNameDescription
20RED_PACKETRed packet
21TRANSFERTransfer
22POKEPoke/Nudge
23CALLVoice/Video call
24SHAREShare (music, mini program, etc.)
25REPLYQuote reply
26FORWARDForward message
27CONTACTContact card

System Message Types (80+)

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

Avatar Format

The avatar and groupAvatar fields 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

When exporting, we recommend compressing avatars to 100×100 pixels or less 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 Exchange Group Chat Backup"
  },
  "meta": {
    "name": "Tech Exchange Group",
    "platform": "wechat",
    "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": "Jane",
      "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 Exchange Group~"
    },
    {
      "sender": "def456",
      "accountName": "Jane",
      "groupNickname": "Moderator",
      "timestamp": 1703001610,
      "type": 1,
      "content": "[Image: screenshot.jpg]"
    }
  ]
}

Private Chat Example

json
{
  "chatlab": {
    "version": "0.0.1",
    "exportedAt": 1703001600
  },
  "meta": {
    "name": "Conversation with Mike",
    "platform": "qq",
    "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 (>1 million messages) to avoid memory overflow issues.

Format Features

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

Line Type Description

_typeDescriptionRequired
headerFile header with chatlab and 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 Exchange Group","platform":"qq","type":"group"}}
{"_type":"member","platformId":"123456","accountName":"John","groupNickname":"Admin"}
{"_type":"member","platformId":"789012","accountName":"Jane"}
{"_type":"message","sender":"123456","accountName":"John","groupNickname":"Admin","timestamp":1703001600,"type":0,"content":"Hello everyone!"}
{"_type":"message","sender":"789012","accountName":"Jane","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, member info will be collected from messages
  3. Messages sorted by time: Recommended to sort by timestamp in ascending order
  4. Each line is independent: Single line parsing errors can be skipped
  5. Comment lines supported: Lines starting with # are skipped (can be used for notes)

Notice

  • Each line must be valid JSON (cannot span lines)
  • Lines are separated by newline \n

Version History

VersionDateChanges
0.0.12025-12Initial version