A powerful CLI tool that converts your study notes (PDF, DOCX, Markdown) into Anki-compatible flashcards using Claude AI.
- 📄 Multiple Input Formats: Supports PDF, DOCX, and Markdown files
- 🤖 AI-Powered: Uses Anthropic's Claude models to intelligently generate flashcards
- 📝 Anki-Compatible: Exports to TXT (tab-separated) and CSV formats
- 🎯 Smart Card Generation: Creates atomic, focused flashcards following spaced repetition best practices
- 🏷️ Auto-Tagging: Automatically tags cards based on the source file
- 👀 Preview Mode: Dry-run option to preview cards before saving
- ⚡ Fast Processing: Typically processes notes in under 30 seconds
- 🛠️ Configurable: Customizable prompts and LLM parameters
- Go 1.21 or higher
- Anthropic API key
# Clone the repository
git clone https://github.com/yourusername/note2anki.git
cd note2anki
# Install dependencies
go mod download
# Build the binary
go build -o note2anki main.go
# Optional: Install globally
go installCreate a .env file in your project root:
ANTHROPIC_API_KEY=your-anthropic-api-key-hereexport ANTHROPIC_API_KEY="your-api-key-here"Create a config.json file:
{
"api_key": "your-anthropic-api-key",
"model": "claude-3-5-haiku-20241022",
"max_tokens": 2000,
"temperature": 0.7
}go mod tidy
go build -o build/note2anki main.gonote2anki <input-file> <output-file># Convert PDF notes to Anki flashcards
note2anki biology_notes.pdf biology_cards.txt
# Convert DOCX to CSV format
note2anki lecture.docx flashcards.csv
# Convert Markdown notes
note2anki chemistry.md chemistry_cards.txt
# Preview cards without saving (dry-run)
note2anki -dry-run physics.pdf preview.txt
# Use custom configuration
note2anki -config custom_config.json notes.pdf cards.txt-config <path>: Path to configuration file-dry-run: Preview first 5 flashcards without saving-help: Show help message
Default Anki import format:
Question[TAB]Answer[TAB]Tags
What is photosynthesis?[TAB]The process by which plants convert light energy into chemical energy[TAB]biology
Spreadsheet-compatible format with headers:
Front,Back,Tags
"What is photosynthesis?","The process by which plants convert light energy into chemical energy","biology"
- Text Extraction: Parses your input file and extracts all text content
- AI Processing: Sends content to Anthropic's Claude model with specialized prompts
- Card Generation: AI identifies key concepts and creates question-answer pairs
- Quality Control: Ensures cards follow Anki best practices (atomic, clear, testable)
- Export: Saves flashcards in Anki-compatible format
The tool generates flashcards following these principles:
- Atomic: One concept per card for optimal retention
- Clear: Unambiguous questions with precise answers
- Contextual: Preserves important context from notes
- Comprehensive: Covers all key concepts, definitions, and relationships
- Active Recall: Questions designed to promote active memory retrieval
You can customize the AI's behavior by modifying the system prompt in your config file:
{
"system_prompt": "Create medical school flashcards focusing on clinical applications..."
}Choose different Claude models based on your needs:
claude-3-5-haiku-20241022: Fast and cost-effective (default)claude-3-5-sonnet-20241022: More accurate and capableclaude-3-opus-20240229: Most powerful for complex tasks
-
"API key not found"
- Set the
ANTHROPIC_API_KEYenvironment variable - Or provide it in a config file
- Set the
-
"No text content found"
- Ensure the PDF is not image-based (scanned documents)
- Check that the file is not corrupted
-
"LLM request failed"
- Verify your API key is valid
- Check your Anthropic account has credits
- Ensure you have internet connectivity
-
Large files taking too long
- Consider splitting very large documents
- Adjust
max_tokensin configuration
- Organize Your Notes: Well-structured notes produce better flashcards
- Use Clear Headings: Help the AI understand topic boundaries
- Include Examples: Examples in notes often become great flashcard content
- Review Generated Cards: Always review Claude-generated content before studying
- Batch Processing: Process related notes together for consistent tagging
- Small files (<10 pages): ~5-10 seconds
- Medium files (10-50 pages): ~15-20 seconds
- Large files (50+ pages): ~20-30 seconds
Note: Processing time depends on file complexity and API response time
- Open Anki Desktop
- Click "File" → "Import"
- Select your generated file
- Configure import settings:
- For TXT: Set field separator to "Tab"
- For CSV: Anki will auto-detect
- Map fields to your note type
- Click "Import"
- Your notes are sent to Anthropic for processing
- No data is stored by this tool
- API keys are never logged or transmitted except to Anthropic
- Consider sensitive content before processing
Contributions are welcome! Please feel free to submit issues and pull requests.
MIT License - See LICENSE file for details
- Support for more file formats (RTF, HTML, EPUB)
- Batch processing multiple files
- Local LLM support (Ollama integration)
- Direct .apkg file generation
- Web interface option
- Custom note types support
- Image-based flashcard support
- Cloze deletion cards
For issues, questions, or suggestions, please open an issue on GitHub.