genanki
Generate Anki decks programmatically
What it is and what it does
genanki is a Python library that lets you build Anki flashcard decks programmatically instead of through the Anki GUI. You define note models (which specify fields and card templates), create individual notes with field values, add them to a deck, and export the result as an .apkg file that Anki can import. The library handles the underlying file format and structure, so you can focus on generating content—useful when you have data in code or a database that you want to turn into flashcards.
The package supports media files (images and audio), custom GUIDs for updating existing notes, YAML-based template definitions, and can even write notes directly to a local Anki collection from within an Anki addon. Its four runtime dependencies (cached-property, frozendict, chevron, pyyaml) are all lightweight, keeping the installation footprint small.
Use it for:
- Generate flashcard decks from CSV or database records without manual Anki data entry
- Create language-learning decks programmatically from vocabulary lists or APIs
- Build study materials for technical subjects by scripting note generation from documentation
- Update existing Anki decks by regenerating and re-importing with stable GUIDs
- Integrate flashcard generation into an automated study-material pipeline
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Generates Anki flashcard decks programmatically in Python, allowing you to create notes, models, and packages that can be imported into Anki.
Yes, if you need to generate Anki decks from code or data. The library is stable, has low install friction, carries no known vulnerabilities, and is permissively licensed. Dormant maintenance is not a blocker for a mature, single-purpose tool—but verify compatibility with your Anki version before relying on it for production workflows.
Install
genanki on PyPI
pip
pip install genankiuv
uv add genankipoetry
poetry add genankiInstalling genanki
Before you install
Low install friction with four lightweight runtime dependencies. Dormant maintenance status (last release 2023-11-12, last commit 2024-12-30) means no active development, but the package is stable and archived repository is not flagged as abandoned.
License in practice
MIT license is permissive, allowing free use, modification, and distribution with minimal restrictions—suitable for both personal and commercial projects.
Quickstart
pip install genanki
import genanki
my_model = genanki.Model(
1607392319,
'Simple Model',
fields=[{'name': 'Question'}, {'name': 'Answer'}],
templates=[{'name': 'Card 1', 'qfmt': '{{Question}}', 'afmt': '{{Answer}}'}])
my_note = genanki.Note(model=my_model, fields=['Q', 'A'])
my_deck = genanki.Deck(2059400110, 'My Deck')
my_deck.add_note(my_note)
genanki.Package(my_deck).write_to_file('output.apkg')
Requires Python 3.6 or later; generated .apkg files must be imported into Anki via File → Import.
Verify before relying
- Whether dormant status affects long-term compatibility with current Anki versions
- Performance characteristics when generating decks with thousands of notes
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.6) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 4 — cached-property, frozendict, chevron, pyyaml |
| Maintenance | dormant — 1,006 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 248,427/month — #8,665 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: genanki-0.13.1-py3-none-any.whl
Keywords: anki, flashcards, memorization
Tags
More Utilities packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
charset-normalizerDetects and normalizes text encoding from…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
PygmentsPygments is a syntax highlighter that colorizes…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
ankiProvides Python access to Anki's core…
agpl · top 15,000 on PyPI
aqtaqt is the Qt-based desktop GUI for Anki, the…
agpl · top 15,000 on PyPI
fsrsImplements the Free Spaced Repetition Scheduler…
permissive · top 15,000 on PyPI
adaptive-cards-templating-pyExpands Adaptive Card templates by substituting…
permissive · top 15,000 on PyPI
essential-generatorsGenerates realistic fake data (emails, URLs,…
permissive · top 15,000 on PyPI
PyLaTeXPyLaTeX generates LaTeX documents and code…
permissive · top 15,000 on PyPI
pyscardpyscard provides Python bindings to interact…
copyleft · top 15,000 on PyPI
sphinx_designA Sphinx extension that adds responsive web…
permissive · top 5,000 on PyPI
pictexPicTex generates high-quality PNG, JPEG, WebP,…
permissive · top 15,000 on PyPI
microsoft-teams-cardsProvides Pydantic-based models for building…
permissive · top 5,000 on PyPI