General Introduction
Chatlog is an open source tool that focuses on extracting and querying chat logs from WeChat's local database. It supports WeChat versions 3.x and 4.0, covering both Windows and macOS systems. Users can view chat logs, contacts, group chats, and recent conversations via command line, terminal interface, or HTTP API operations. MCP SSE protocol, which can be integrated with AI assistants (e.g. ChatWise) to quickly analyze chat data. The project is based on Apache-2.0 license, open code, safe and reliable, suitable for users who need to organize or analyze WeChat data.
Function List
- Extract chat logs, contacts, group chats and recent conversations from WeChat's local database.
- Supports WeChat version 3.x and 4.0, compatible with multiple data formats.
- Provides terminal interface (TUI) and command line tools for intuitive operation.
- Built-in HTTP API to support querying chat logs, contacts, group chats and other information.
- Supports the MCP SSE protocol for seamless connectivity with compatible AI assistants.
- Provide data decryption function to ensure that users can securely access local data.
- Open source code with user checkable security or customizable features.
Using Help
The goal of Chatlog is to allow users to easily extract and query WeChat chat logs. Below is a detailed installation and usage guide to help users get started quickly.
Installation process
Chatlog requires some technical operation and is suitable for users with basic knowledge. Below are the installation steps:
- Preparing the environment
Make sure the following software is installed on your computer:- Go: The latest version is recommended, see the Go website for installation instructions.
- Xcode(macOS users): Download from the App Store for key extraction.
- WeChat Client: Ensure that you are installed and logged in, and chat logs need to be migrated to your computer.
- Installation from source
Open a terminal and run the following command to install Chatlog:go install github.com/sjzar/chatlog@latest
After installation, Chatlog can be run directly from the command line.
- Download pre-compiled version
If you don't want to compile from source, visit GitHub Releases and download a pre-compiled version for your system (e.g. Windows or macOS). Once downloaded, unzip it and use it. - macOS users turn off SIP
On macOS, due to security restrictions, you need to temporarily disable SIP when extracting the key, as follows:- Enter recovery mode:
- Intel Mac: Press and hold the
Command + R
key to turn on the computer until the Apple logo appears. - Apple Silicon Mac: Press and hold the power button after shutting down the computer until you see the boot option.
- Intel Mac: Press and hold the
- Open a terminal and type:
csrutil disable
- Reboot the system:
sudo reboot
- After extracting the key, it is recommended to re-enable the SIP (run the
csrutil enable
(and reboot).
- Enter recovery mode:
- Migrate WeChat Chat Records
Operate in mobile WeChat:- Open "Me - Settings - General - Chat History Migration & Backup - Migration - Migrate to PC".
- Follow the instructions to transfer the chat records to your computer WeChat client. This operation will not affect the cell phone data.
Main Functions
Chatlog provides multiple ways to manage WeChat chat data, here is how to use the core features:
- Extract and decrypt data
After running Chatlog, the program prompts for the path to the WeChat database (usually found on macOS).~/Library/Containers/com.tencent.xinWeChat/Data/Library/Application Support/com.tencent.xinWeChat/
(or the WeChat installation directory for Windows). After entering the path, run the following command to decrypt the data:./chatlog decrypt
The decrypted data can be used for query or display.
- Terminal Interface (TUI) Operations
Launch the terminal interface:./chatlog
Method of operation:
- Use the arrow keys to navigate the menu.
- check or refer to
Enter
Select the option. - check or refer to
Esc
Return to previous level. - check or refer to
Ctrl+C
Withdrawal from the program.
The terminal interface displays chat logs, contacts and other information, suitable for quick viewing.
- command-line query
Get the microsoft data key:./chatlog key
Query specific data (e.g. chat logs)
./chatlog decrypt
The command line is suitable for batch operations or script processing.
- HTTP API Usage
Start the HTTP service (default port 5030):./chatlog
Access via browser
http://127.0.0.1:5030
View the data, or query it using the API:- chat log::
GET /api/v1/chatlog?time=2023-01-01&talker=wxid_xxx&limit=100&offset=0&format=json
Parameter Description:
time
: Time range, e.g.2023-01-01
maybe2023-01-01~2023-12-31
Thetalker
: Chat ID, support WeChat ID, nickname or group chat ID.limit
: Returns the number of records.offset
: Paging offset.format
: Output format (json
,csv
(or text).
- Contact List::
GET /api/v1/contact
- Group Chat List::
GET /api/v1/chatroom
- recent session::
GET /api/v1/session
- chat log::
- Browser View
After starting the HTTP service, open a browser to access thehttp://127.0.0.1:5030
. The page displays chat records, contacts and other content, supports sorting by time or object, and operates intuitively.
Featured Function Operation
Chatlog's uniqueness lies in its open source design and AI integration, and here are the details of the features:
- MCP SSE Protocol Integration
Chatlog supports the MCP SSE protocol for connecting with AI assistants (e.g. ChatWise, Claude). Setup steps:- Start Chatlog's HTTP service.
- Add a new tool to the AI Assistant settings:
- Type:
sse
The - URL:
http://127.0.0.1:5030/sse
The - Check the box "Automate tools".
- Type:
- After configuration, the AI assistant can directly query chat records. For example, if you type "Find chats with Xiaoming yesterday" in ChatWise, the assistant will return the corresponding records.
- If the AI tool does not support MCP SSE, you can use the mcp-proxy Forward the request. For example, the Claude Editing in Desktop
config.json
::{ "mcpServers": { "mcp-proxy": { "command": "/path/to/mcp-proxy", "args": ["http://localhost:5030/sse"], "env": {} } } }
- Open Source and Customization
Chatlog is based on the Apache-2.0 license, and the code is publicly available so that users can check security or modify functionality. For example:- Add a new export format (e.g. CSV):
- compiler
src/export.go
, add export logic. - (of a computer) run
go build
Recompile.
- compiler
- Optimize query speed:
- modifications
src/query.go
, adjusting the database index.
The open source design allows users to expand functionality as needed.
- modifications
- Add a new export format (e.g. CSV):
Supplementary functions (mentioned in the official description but missing from the original presentation)
- Multi-system support
Chatlog is compatible with both Windows and macOS, and the process is consistent to ensure cross-platform access. - Planning Functions (TODO)
According to the official note, Chatlog will be supported in the future:- Multimedia data (e.g., images, speech) extraction.
- Full-text indexing of chat data to speed up searches.
- Statistical dashboard showing analytics such as message frequency, keywords, etc.
These features are not yet live, but show the direction of the project's continuous improvement.
caveat
- data security: Chatlog only processes local data and does not upload to the web. Users can check the code via GitHub to confirm security.
- SIP operation: macOS users need to disable SIP only when extracting keys, and re-enable it when they are done.
- WeChat version: Make sure the WeChat client is version 3.x or 4.0, other versions may not be compatible.
- Backup Data: It is recommended to back up your microsoft database files regularly to prevent accidental loss.
With these steps, users can easily install Chatlog, extract chat logs, or analyze the data with APIs and AI assistants.
application scenario
- Organize chat logs
Users want to save WeChat messages with friends or group chats, Chatlog can extract and organize the records for easy archiving or exporting. - Group Chat Management
When a group chat is overloaded with messages, Chatlog can be used by group administrators to quickly look up what specific members have said or keywords. - data analysis
Developers need statistics on chat frequency or keywords, and Chatlog's HTTP API provides structured data suitable for research or reporting. - AI collaboration
Users want an AI assistant to find out what they're chatting about, and Chatlog's MCP SSE support lets AI read and analyze the data directly.
QA
- What systems does Chatlog support?
Supports Windows and macOS and is compatible with WeChat versions 3.x and 4.0. - How to ensure data security?
Chatlog is an open source tool where data is only processed locally, the code is publicly available for inspection and is not uploaded to the web. - macOS Why do I need to turn off SIP?
WeChat's security mechanism restricts key extraction, and disabling SIP is a temporary operation that can be re-enabled after completion. - What data queries does the API support?
Support for chat logs, contacts, group chats, and recent session lookups in both JSON and CSV formats. - How does it integrate with AI assistants?
Start Chatlog's SSE service and configure the AI assistant's tool URL to behttp://127.0.0.1:5030/sse
Ready to go.