WeChat SQLite: Dig Into Your Desktop Chat History with Raw SQL
If you've ever wanted to programmatically analyze your WeChat messages—maybe to track conversation trends, export contacts, or build a personal analytics dashboard—you know the official client doesn't make it easy. But behind the scenes, your WeChat desktop app stores everything in a local SQLite database.
That's where WeChat SQLite comes in. It's a command-line tool that decrypts and exposes the SQLite database from your WeChat installation, letting you query chat records, contacts, and more with plain old SQL—no reverse engineering or fumbling with binary files required.
What It Does
This tool extracts the encrypted SQLite database from your local WeChat (Windows/macOS) installation, decrypts it using the account's session key, and gives you a standard .db file you can open with any SQLite client (like sqlite3, DB Browser, or your own code). Under the hood, it handles the custom encryption WeChat uses (AES with your account-specific key), saving you the headache of figuring out the decryption routine yourself.
The repo also includes schema documentation so you know which tables store messages (MSG), contacts (Contact), and chat rooms (ChatRoom). Once you have the decrypted file, you can run queries like:
SELECT StrContent, CreateTime FROM MSG
WHERE StrTalker = 'wxid_xxx'
ORDER BY CreateTime DESC LIMIT 50;
Why It’s Cool
No GUI overhead. This is a CLI tool, perfect for devs who want to automate or script analysis. You can pipe the exported database into a Python script with sqlite3, or feed it into a visualization tool like Grafana.
Handles the tricky part. WeChat's local database is encrypted per-account and includes variable-length fields and custom offsets. The tool abstracts all that away. Just run it, point it at your WeChat install path, and get a clean SQLite file.
Privacy-first, local-only. Everything stays on your machine. The tool never sends data anywhere. You're running it entirely offline, which is a big deal for a messenger with as much personal data as WeChat.
How to Try It
Clone the repo and read the setup notes—most of the magic is in decrypting the database key from your WeChat process memory. The author provides clear steps for both Windows and macOS (Linux doesn't natively run WeChat desktop, so that's out of scope).
git clone https://github.com/adysec/wechat_sqlite.git
cd wechat_sqlite
# See README for steps to extract decryption key
# Then run the decryption script
python decrypt.py --path /path/to/wechat/data
You'll need Python 3.8+ and the pycryptodome library. The README has specific instructions for dumping the session key from memory (using a bundled tool). Once you have the .db file:
sqlite3 decrypted.db
.tables
SELECT COUNT(*) FROM MSG;
That's it. Your chat history, now a database.
Final Thoughts
WeChat SQLite is a practical tool if you're doing any kind of forensic, analytical, or archival work with WeChat. The encryption pattern is common across many Chinese apps (AES with a per-session key stored in memory), so the techniques here might even transfer to other tools.
It's not flashy, but it solves a real pain point: giving developers programmatic access to a closed ecosystem's local data without needing to capture network traffic or manually explore binary files. If you've ever wished you could SELECT * FROM messages WHERE ... on your chat history, this is your answer.
Found this useful? Follow @githubprojects for more developer-focused open source tools and projects.