A simple web-based viewer for OpenWebUI chat logs stored in SQLite database.
- Browse all chat sessions
- View complete message history for each chat
- Clean, responsive UI
- Handles various OpenWebUI database schema versions
- Debug endpoints for troubleshooting
- Python 3.7 or higher
- Your OpenWebUI database file (usually
webui.db)
pip install flask --break-system-packagesEdit app.py and update the DB_PATH variable to point to your database file:
DB_PATH = 'webui_backup_20250918_102142.db' # Update this pathOr use a relative/absolute path:
DB_PATH = '/path/to/your/webui.db'Before running the app, it's helpful to understand your database structure:
python3 inspect_db.py /path/to/your/webui.dbThis will show you:
- All tables in the database
- Column structure of the chat table
- Sample chat data structure
- Message extraction attempt
python3 app.pyThe server will start on http://0.0.0.0:5000
Open your browser and navigate to:
- Local:
http://localhost:5000 - Network:
http://YOUR_IP:5000(from other devices on your network)
Solution 1: Use the Debug Endpoint
Visit: http://localhost:5000/api/debug/chat/<chat_id>
Replace <chat_id> with the ID of a chat (you can get this from the chat list).
This will show you:
- The raw database structure
- Parsed JSON structure
- Available keys in the chat data
Solution 2: Check the Console
Open your browser's developer console (F12) and look for:
- JavaScript errors
- The structure of the data being received
- Network request failures
Solution 3: Check Server Logs
The Flask server will print errors to the terminal. Look for:
- JSON parsing errors
- Database query errors
- Python exceptions
Make sure:
- The database file path in
app.pyis correct - The file has read permissions:
chmod 644 your_database.db - You're running the app from the correct directory
This could mean:
- The database file is empty or corrupted
- The schema is different than expected
- Check with:
python3 inspect_db.py your_database.db
The chat column can have different JSON structures:
Structure 1: Direct messages array
{
"messages": [
{"role": "user", "content": "Hello"},
{"role": "assistant", "content": "Hi there!"}
]
}Structure 2: Nested in history
{
"history": {
"messages": [...]
}
}Structure 3: Top-level properties
{
"id": "...",
"messages": [...],
"title": "..."
}The application attempts to handle all these variations automatically.
Returns list of all chats:
[
{
"id": "chat_id",
"title": "Chat title",
"created_at": 1234567890,
"updated_at": 1234567890
}
]Returns messages for a specific chat:
{
"title": "Chat title",
"messages": [...],
"raw_structure": ["messages", "title", ...]
}Returns complete raw database record with parsed JSON for debugging.
Edit app.py:
app.run(host='0.0.0.0', port=8080, debug=True) # Change port hereThe CSS is embedded in templates/index.html. You can modify:
- Colors
- Fonts
- Layout dimensions
- Message styling
The createMessageElement() function in index.html handles message rendering. Modify this to:
- Add markdown support
- Format code blocks
- Add timestamps
- Change message appearance
- Do not expose to the public internet without authentication
- The debug endpoint reveals database contents
- Flask debug mode should be disabled in production
- Consider adding authentication if needed
.
├── app.py # Flask backend
├── templates/
│ └── index.html # Frontend HTML/CSS/JS
├── inspect_db.py # Database inspection tool
├── README.md # This file
└── webui_backup_*.db # Your database file
The issue is in the message content parsing. Check the createMessageElement() function in index.html.
Different chats might have different JSON structures. The code attempts to handle variations, but you might need to add custom logic for your specific schema.
For databases with thousands of chats or very long conversations:
- Add pagination to the chat list
- Implement message loading limits
- Add search/filter functionality
For issues related to:
- OpenWebUI itself: https://github.com/open-webui/open-webui
- This viewer: Check the debug endpoints and inspect_db.py output
This is a simple utility script provided as-is for personal use.