- Click "Export Messages Now" in AiMessage
- The export script will be saved to your Downloads folder (or copied to clipboard)
- Open Terminal and run the script
- Import the CSV file back into AiMessage
AiMessage is a sandboxed app for your security. This means:
- ✅ The app can't access your private data without permission
- ✅ Your messages stay private and secure
- ❌ The app can't directly read the Messages database
Since the app can't access Messages directly, it creates a script that you run in Terminal. This approach:
- Keeps the app sandboxed (safer)
- Gives you full control over the export
- Shows exactly what data is being accessed
- Open AiMessage
- Go to Import tab
- Click "How to Export"
- Click "Export Messages Now"
The app will try to:
- Save script to Downloads folder (usually works)
- If that fails, copy script to clipboard
If saved to Downloads:
~/Downloads/export_imessages_[timestamp].shIf copied to clipboard:
# In Terminal, paste and save:
pbpaste > ~/Desktop/export.sh && chmod +x ~/Desktop/export.sh
~/Desktop/export.shIf you see "Operation not permitted":
- Open System Settings
- Go to Privacy & Security → Full Disk Access
- Add Terminal (click + and select from Applications/Utilities)
- Restart Terminal
After the script runs successfully:
- Find the CSV file on your Desktop
- Drag it into AiMessage
- Start analyzing!
Q: Why can't the app export directly? A: macOS sandboxing prevents apps from accessing your Messages database. This is a security feature.
Q: Is this safe? A: Yes! The script only reads data, never modifies it. You can review the script before running.
Q: Why Terminal and not the app? A: Terminal runs outside the sandbox and can access Messages with your permission.
- The app will copy to clipboard instead
- Follow the clipboard instructions above
- Grant Terminal Full Disk Access (see step 3)
- Make sure Messages app is closed
- Verify Messages has been set up on this Mac
- Check that you have message history
If you prefer, you can manually run this SQL query in Terminal:
sqlite3 ~/Library/Messages/chat.db <<EOF
.mode csv
.headers on
.output ~/Desktop/messages_export.csv
SELECT
datetime(date/1000000000 + 978307200, 'unixepoch', 'localtime') as timestamp,
text,
CASE is_from_me WHEN 1 THEN 'Me' ELSE handle.id END as sender,
is_from_me as isFromMe,
'chat' as chatIdentifier
FROM message
LEFT JOIN handle ON message.handle_id = handle.ROWID
WHERE text IS NOT NULL
ORDER BY date DESC;
.quit
EOF- All processing happens locally on your Mac
- No data is sent to any servers
- The export script is generated locally
- You have full control over your data