skillfed

genanki

Generate Anki decks programmatically

genanki v0.13.1 248.4K downloads/30d#8,665 on PyPI2,672
Permissive license MIT DORMANT released

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 genanki

uv

uv add genanki

poetry

poetry add genanki

Installing 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

anki deck generation pythonprogrammatic flashcard creationanki package builderspaced repetition deck generatoranki importer library
flashcardsstudy-toolsdata-generation

More Utilities packages