A Python tool to organize and structure Bitwarden JSON exports with AI-powered automatic categorization and tagging.
- π€ AI-Powered Categorization: Uses OpenAI GPT models for intelligent, context-aware categorization
- π§ Smart Name Suggestions: AI-generated descriptive names for better organization
- π·οΈ Intelligent Tagging: Context-aware tag generation based on content and purpose
- π Folder Organization: Creates and assigns folders for personal vaults
- π’ Collection Management: Handles organization vaults with collections
- π Rule-Based Fallback: Automatic fallback to pattern-based rules if AI fails
- π‘οΈ Safe Processing: Never modifies usernames, passwords, or TOTP secrets
- π Metadata Enhancement: Adds structured notes with AI insights and metadata
- Python 3.8 or higher
- Poetry (recommended) or pip
# Clone the repository
git clone https://github.com/yourusername/bitwarden-organizer.git
cd bitwarden-organizer
# Install dependencies
poetry install
# Activate virtual environment
poetry shell
# Set up OpenAI API key
cp env.example .env
# Edit .env file with your OpenAI API key
pip install bitwarden-organizer
# Basic usage (rule-based)
bitwarden-organize input.json
# AI-powered organization
bitwarden-organize input.json --ai
# Specify output file
bitwarden-organize input.json -o organized_output.json
# AI with custom model and batch size
bitwarden-organize input.json --ai --ai-model gpt-4 --ai-batch-size 20
# AI with local model (Ollama)
bitwarden-organize input.json --ai --ai-model llama-3.1-8b --ai-base-url http://localhost:11434/v1
# AI with local model (LocalAI)
bitwarden-organize input.json --ai --ai-model llama-2-7b-chat --ai-base-url http://localhost:8080/v1
# Dry run (preview changes without writing)
bitwarden-organize input.json --dry-run
# Help
bitwarden-organize --help
from bitwarden_organizer import organize_bitwarden_export
# Organize export data
organized_data = organize_bitwarden_export(input_data)
# Save to file
with open('output.json', 'w') as f:
json.dump(organized_data, f, indent=2)
The tool processes Bitwarden exports and:
- π€ AI Categorization: Uses GPT models to intelligently categorize entries
- π§ Smart Naming: AI-generated descriptive names for better identification
- π·οΈ Intelligent Tagging: Context-aware tag generation based on content analysis
- π Batch Processing: Efficiently processes items in configurable batches
- π Smart Fallback: Automatically falls back to rules if AI fails
The tool now supports local AI models through custom base URLs:
- π§ Ollama: Use local models like llama-3.1-8b, codellama, mistral
- π LocalAI: Self-hosted models with Docker support
- π» LM Studio: Local model management and serving
- π Custom Endpoints: Any OpenAI-compatible API endpoint
Example with Ollama:
# Set environment variables
export OPENAI_API_KEY="ollama"
export OPENAI_BASE_URL="http://localhost:11434/v1"
export OPENAI_MODEL="llama-3.1-8b"
# Run with local model
bitwarden-organize export.json --ai
Example with CLI arguments:
bitwarden-organize export.json --ai \
--ai-model llama-3.1-8b \
--ai-base-url http://localhost:11434/v1
See LOCAL_MODELS.md for detailed setup instructions.
- π Pattern Analysis: Analyzes URLs and domains for categorization
- π Folder Creation: Creates folders for personal vaults (if missing)
- π’ Collection Assignment: Assigns collections for organization vaults
- π·οΈ Rule-Based Tagging: Adds tags based on domain patterns
- π Metadata Structuring: Adds structured notes with metadata headers
- βοΈ Name Suggestions: Suggests cleaner names based on domain analysis
- π‘οΈ Data Integrity: Never touches sensitive fields (passwords, TOTP, etc.)
The tool automatically categorizes entries into:
The AI model can intelligently categorize entries into any relevant category based on context, including:
- Finance: Banking, payment processors, crypto exchanges, investments
- Social: Social media platforms, community sites, communication tools
- Developer: Code repositories, development tools, CI/CD, APIs
- Cloud: Cloud providers, infrastructure services, hosting platforms
- Email: Email providers, identity services, communication
- Shopping: E-commerce platforms, retail sites, marketplaces
- Government/Utilities: Government services, utility providers, official portals
- Travel: Travel booking, transportation services, accommodation
- Security: Security tools, authentication, password managers
- Entertainment: Streaming services, gaming platforms, media
- Education: Learning platforms, courses, academic resources
- Health: Healthcare services, fitness platforms, medical resources
- Business: Business tools, productivity software, professional services
- General: Everything else
- Finance: Banking, payment processors, crypto exchanges
- Social: Social media platforms, community sites
- Developer: Code repositories, development tools, CI/CD
- Cloud: Cloud providers, infrastructure services
- Email: Email providers, identity services
- Shopping: E-commerce platforms, retail sites
- Government/Utilities: Government services, utility providers
- Travel: Travel booking, transportation services
- Security: Security tools, password managers
- π‘οΈ Read-only processing of sensitive data
- πΎ Backup recommendation before processing
- π Dry-run mode to preview changes
- β Validation of input/output data
- π¨ Error handling for malformed data
- π AI fallback to rule-based processing if needed
- π Secure API handling for OpenAI integration
# Install development dependencies
poetry install --with dev,test
# Install pre-commit hooks
pre-commit install
# Run tests
poetry run pytest
# Run linting
poetry run black .
poetry run isort .
poetry run flake8 .
poetry run mypy .
bitwarden-organizer/
βββ bitwarden_organizer/
β βββ __init__.py
β βββ core.py # Main organization logic
β βββ cli.py # Command-line interface
β βββ ai_config.py # AI configuration and OpenAI integration
β βββ utils.py # Utility functions
βββ tests/
β βββ __init__.py
β βββ test_core.py
β βββ test_cli.py
βββ validation/
β βββ validate_bitwarden_export.py # Main validation script
β βββ test_validation.py # Test script for validation
β βββ test_validation_errors.py # Error scenario tests
β βββ validate.sh # Shell script wrapper
βββ pyproject.toml # Poetry configuration
βββ env.example # Environment variables template
βββ README.md
βββ VALIDATION_README.md # Validation documentation
βββ .gitignore
After organizing your Bitwarden export, you can validate the integrity and quality of the output using our validation script.
# Using the shell script (recommended)
./validate.sh bw.json bw_organized.json
# Using Python directly
python validate_bitwarden_export.py bw.json bw_organized.json
# Using Make
make validate INPUT=bw.json OUTPUT=bw_organized.json
- Data Integrity: Item count, credentials preservation, core data integrity
- Organization Quality: Folders created, collections created, tags assigned
- Metadata Preservation: Notes, URIs, creation dates, revision dates
- Structure Validation: JSON format, required fields, vault type detection
# Test with sample data
make validate-test
# Test error scenarios
make validate-test-errors
The script generates a comprehensive report showing:
- β Pass/fail status for each validation check
- π Statistics about organization improvements
β οΈ Warnings for non-critical issues- β Errors that prevent safe import
- π― Overall recommendation for import
For detailed documentation, see VALIDATION_README.md.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
Create a .env
file in the project root with your LOCAL OpenAI compatible endpoints configuration:
Local Model Configuration:
# For Ollama
OPENAI_BASE_URL=http://localhost:11434/v1
OPENAI_MODEL=llama-3.1-8b
# For LocalAI
OPENAI_BASE_URL=http://localhost:8080/v1
OPENAI_MODEL=llama-2-7b-chat
# For custom endpoints
OPENAI_BASE_URL=https://your-endpoint.com/v1
OPENAI_MODEL=your-model-name
- Never commit your
.env
file to version control - Use environment variables in production
- Consider using a secrets manager for sensitive keys
This tool processes sensitive password data. Always:
- Test on a copy of your export first
- Verify the output before importing back to Bitwarden
- Keep your original export as a backup
- Use in a secure environment
- DO NOT USE NON-LOCAL inference. i.e. OPEN AI etc. Make sure to only use locally hosted models (everything is done locally on your machine).