AnkiView ๐ด
April 12, 2026 ยท View on GitHub
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.
Features โจ
- 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
- Tag management - Add, remove, or replace tags on notes via CLI
- Edit notes - Open any note in your
$EDITORwith a type-aware template - Bulk tag operations - Rename, bulk-add, or bulk-remove tags across notes
- Smart updates - Automatically track cards with ID comments; tags merged on re-import
- 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)
Installation ๐
From Source
# Clone the repository
git clone https://github.com/yourusername/ankiview
cd ankiview
# Build and install
cargo install --path .
Prerequisites
- Rust 1.70 or higher
- An Anki installation with at least one profile
Usage ๐ก
View a note
View a note by its ID:
ankiview view 1234567890
Use a specific collection file:
ankiview -c /path/to/collection.anki2 view 1234567890
Specify an Anki profile:
ankiview -p "User 1" view 1234567890
Delete a note
Delete a note by its ID:
ankiview delete 1234567890
Warning: 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 1234567890
List notes
List all notes in your collection with their IDs and first line of content:
ankiview list
Filter 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 available card types
List all card types (notetypes) available in your Anki collection:
ankiview list-card-types
This shows you which card types you can use with the --card-type flag.
Manage tags
Add or remove tags on individual notes:
# Add tags to a note
ankiview tag add 1234567890 review urgent
# Add a hierarchical tag
ankiview tag add 1234567890 "topic::math::algebra"
# Remove tags from a note
ankiview tag remove 1234567890 review
Replace, bulk-add, or bulk-remove tags across the collection:
# Rename a tag on all notes
ankiview tag replace --old "review" --new "reviewed"
# Add a tag to all notes
ankiview tag replace --old "" --new "batch-2026"
# Remove a tag from all notes
ankiview tag replace --old "obsolete" --new ""
# Scope to specific notes using Anki search syntax
ankiview tag replace --old "review" --new "reviewed" --query "deck:Physics"
Edit a note
Open a note in your $EDITOR for full editing of fields and tags:
ankiview edit 1234567890
The editor opens a structured template adapted to the note type:
- Basic notes show Front/Back fields
- Cloze notes show Text/Extra fields
- Custom note types show their actual field names
Fields are presented as raw HTML. Tags can be edited in the same session. The template is validated before saving (empty required fields and missing cloze deletions are rejected).
Collect markdown cards
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.md
Markdown 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
- Merges tags from markdown onto existing notes (additive only โ tags are never removed by
collect) - 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 language
This 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.
Debug logging
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 works
How It Works ๐ง
AnkiView:
- 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
Example Output ๐
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
Development ๐
The project structure:
src/
โโโ application/ # Use cases: NoteViewer, NoteUpdater, TagManager, NoteEditor, ...
โโโ cli/ # Command-line interface (clap)
โโโ domain/ # Core domain models (Note, DomainError)
โโโ infrastructure/ # Adapters: AnkiRepository, NoteTemplate, renderers
โโโ inka/ # Card collection subsystem (markdown โ Anki)
โโโ ports/ # Output adapters (HtmlPresenter)
Running Tests
# Run all tests
cargo test
# Run with logging
RUST_LOG=debug cargo test
Troubleshooting ๐
Common Issues
-
"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
-
Tags not removed after editing markdown (collect command)
- This is by design:
collectonly adds tags (merge-only semantics) - Use
ankiview tag remove <NOTE_ID> <tag>to remove tags
- This is by design:
-
"Editor exited with non-zero status" (edit command)
- Your editor quit abnormally; the edit was aborted
- Check the
EDITORenvironment variable is set correctly
-
"Cloze note Text field must contain at least one cloze deletion" (edit command)
- Cloze notes require
{{c1::...}}syntax in the Text field - Add at least one cloze deletion before saving
- Cloze notes require
Contributing ๐ค
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
Acknowledgments ๐
- Anki - The amazing flashcard program