A command-line tool for managing Anki collections: view, search, delete notes, and import markdown flashcards β all without opening Anki.
It serves also as a much more powerfull drop-in replacement for inka2.
- View notes - View any note by its ID in your default browser
- Delete notes - Delete notes from your collection via CLI
- List notes - Browse and search notes from the command line
- List card types - See available card types in your collection
- Import markdown - Convert markdown flashcards to Anki notes
- Smart updates - Automatically track cards with ID comments
- Media handling - Import images from markdown files
- Hash caching - Skip unchanged files for fast re-imports
- Custom card types - Use any card type from your collection
- Automatic collection file detection
- Support for multiple Anki profiles
- LaTeX math rendering support
- Clean, modern card presentation
- Cross-platform support (Windows, macOS, Linux)
# Clone the repository
git clone https://github.com/yourusername/ankiview
cd ankiview
# Build and install
cargo install --path .- Rust 1.70 or higher
- An Anki installation with at least one profile
View a note by its ID:
ankiview view 1234567890Use a specific collection file:
ankiview -c /path/to/collection.anki2 view 1234567890Specify an Anki profile:
ankiview -p "User 1" view 1234567890Delete a note by its ID:
ankiview delete 1234567890Warning: Deletion is permanent and will remove the note and all associated cards from your collection.
Global flags work with all commands:
ankiview -c /path/to/collection.anki2 delete 1234567890
ankiview -p "User 1" delete 1234567890List all notes in your collection with their IDs and first line of content:
ankiview listFilter notes by searching the front field:
ankiview list "rust programming"This is useful for:
- Finding note IDs when you know the content
- Browsing your collection from the command line
- Quick searches without opening Anki
List all card types (notetypes) available in your Anki collection:
ankiview list-card-typesThis shows you which card types you can use with the --card-type flag.
Import markdown flashcards into your Anki collection:
# Import a single file
ankiview collect notes.md
# Import a directory (non-recursive)
ankiview collect notes/
# Import recursively (all subdirectories)
ankiview collect -r notes/
# Use a specific card type
ankiview collect --card-type "Basic" notes.mdMarkdown Format
Basic cards (question and answer):
---
Deck: Programming
Tags: rust basics
1. What is Rust?
> A systems programming language
2. What is Cargo?
> Rust's package manager
---Cloze deletion cards:
---
Deck: Programming
1. Rust provides {memory safety} without garbage collection.
2. The {{c1::borrow checker}} ensures {{c2::safe concurrency}}.
---Cards with images:
---
Deck: ComputerScience
1. What type of graph is this?
> 
> A directed acyclic graph (DAG)
---How It Works
- AnkiView reads your markdown files
- Creates or updates notes in Anki
- Injects ID comments into your markdown for tracking
- Copies media files to Anki's collection.media/
After the first run, your markdown will have ID comments:
<!--ID:1686433857327-->
1. What is Rust?
> A systems programming languageThis allows you to edit the content and re-run collect to update (not duplicate) the cards.
Advanced Usage
# Use a specific card type (defaults to "Inka Basic")
ankiview collect --card-type "Basic" notes/
# Recover lost IDs by searching Anki
ankiview collect -u notes/
# Force rebuild (bypass cache)
ankiview collect -f notes/
# Overwrite existing media files
ankiview collect --force notes/
# Continue on errors, report at end
ankiview collect -i notes/
# Combine flags for batch processing
ankiview collect -ri --card-type "Basic" notes/Flag Reference
| Flag | Description |
|---|---|
-r, --recursive |
Process subdirectories |
--force |
Overwrite conflicting media files |
-i, --ignore-errors |
Continue processing on errors |
-f, --full-sync |
Bypass hash cache (force rebuild) |
-u, --update-ids |
Search Anki for existing notes by content |
--card-type TYPE |
Use specific card type (defaults to "Inka Basic") |
Performance Note: AnkiView maintains a hash cache to skip unchanged files. Use -f to force processing all files.
Enable debug logging for any command (global flags can appear before or after subcommand):
ankiview -v delete 1234567890 # DEBUG level
ankiview -vv view 1234567890 # TRACE level
ankiview delete -v 1234567890 # Also worksAnkiView:
- Locates your Anki collection file
- Opens the collection safely (read-only)
- Retrieves the specified note
- Generates a beautiful HTML preview
- Opens it in your default browser
When you view a note, you'll see:
- The question and answer clearly separated
- Properly rendered LaTeX equations
- Card tags and metadata
- Clean, modern styling
The project structure:
src/
βββ application/ # Use cases and business logic
βββ cli/ # Command-line interface
βββ domain/ # Core domain models
βββ infrastructure/ # External interfaces (Anki, browser)
βββ ports/ # Input/output adapters
# Run all tests
cargo test
# Run with logging
RUST_LOG=debug cargo test-
"Collection file not found"
- Ensure Anki is installed
- Check if the profile name is correct
- Verify the collection path
-
"Failed to open Anki collection"
- Make sure Anki isn't running (required for all commands)
- Check file permissions
-
"Notetype '...' not found" (collect command)
- The specified card type doesn't exist in your collection
- Run
ankiview list-card-typesto see available types - Omit
--card-typeto use the default "Inka Basic" - Create the card type in Anki first if needed
-
"Different file with the same name already exists" (collect command)
- Media file conflict detected
- Use
--forceflag to overwrite existing media files - Or rename your image file to avoid conflict
-
Duplicate cards created (collect command)
- Ensure ID comments (
<!--ID:-->) are preserved in markdown - Use
--update-idsflag to recover lost IDs - Check that you didn't manually modify or remove ID comments
- Ensure ID comments (
-
Cards not updating (collect command)
- File may be unchanged (check hash cache)
- Use
-fflag to force rebuild - Verify ID comments are correct and match Anki notes
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Anki - The amazing flashcard program