Skip to content

anki_deck_from_text

PyPI version CI Tests License: MIT Python 3.12+

Generate Anki flashcard decks (.apkg) from annotated text files.

Mark vocabulary lines in any text file, and anki_deck_from_text will turn them into a ready-to-import Anki deck.

Quick example

Given an input file vocab.txt:

Some notes you don't want as cards...

- casa = house
- gato = cat
- perro = dog

More notes here...

Run:

anki_deck_from_text vocab.txt spanish_vocab "Spanish Vocabulary"

This creates spanish_vocab.apkg with three cards, ready to import into Anki.

Features

  • Simple annotation format -- mark lines with a character (default -) and separate front/back with another (default =)
  • Automatic encoding detection -- handles UTF-8, Latin-1, and other encodings via chardet
  • Multiple card types -- built-in basic and sound models, with support for custom models
  • Reverse cards -- swap front and back with --reverse
  • Dry run / preview -- see what cards would be generated before writing the file
  • Tags -- add comma-separated Anki tags to all cards
  • Merge multiple files -- combine several input files into one deck with -i

Next steps