https://github.com/5mdld/anki-apkg-extractor
Extract Anki .apkg packages into notes + templates + media. Supports Anki collection SQLite formats: collection.anki21b, collection.anki21, collection.anki2.
https://github.com/5mdld/anki-apkg-extractor
anki apkg csv extractor flashcards media protobuf protocol-buffers python python3 spaced-repetition sqlite templates zstandard zstd
Last synced: 3 months ago
JSON representation
Extract Anki .apkg packages into notes + templates + media. Supports Anki collection SQLite formats: collection.anki21b, collection.anki21, collection.anki2.
- Host: GitHub
- URL: https://github.com/5mdld/anki-apkg-extractor
- Owner: 5mdld
- License: mit
- Created: 2025-08-27T10:28:14.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2026-03-11T06:45:40.000Z (4 months ago)
- Last Synced: 2026-03-29T01:25:31.610Z (4 months ago)
- Topics: anki, apkg, csv, extractor, flashcards, media, protobuf, protocol-buffers, python, python3, spaced-repetition, sqlite, templates, zstandard, zstd
- Language: Python
- Homepage: https://ankiweb.net/shared/by-author/842333142
- Size: 24.4 KB
- Stars: 6
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Anki APKG Extractor
Extract Anki `.apkg` packages into notes + templates + media. Supports Anki collection SQLite formats: `collection.anki21b`, `collection.anki21`, `collection.anki2`.
## Requirements
- Python ≥ 3.8
- Optional for 21b: `pip install "zstandard>=0.19" "protobuf>=4.21"`
## Configuration
You can configure the output format of `notes.csv` by modifying the global variables at the top of the `anki_apkg_extract.py` script:
```python
# --- Output Settings ---
CSV_SEPARATOR = "tab" # "comma", "tab", "semicolon", "space", "pipe", "colon"
CSV_HTML = True # True: keep HTML, False: strip HTML and media references
CSV_GUID_COL = True # Output guid column
CSV_NOTETYPE_COL = True # Output notetype column
CSV_DECK_COL = True # Output deck column
CSV_TAG_COL = True # Output tags column
```
## Usage
```bash
# scan *.apkg next to the script
python anki_apkg_extract.py
# specify files or a directory; overwrite without prompt
python anki_apkg_extract.py --apkg /path/to/a.apkg /dir/with/apkg --yes
# or skip prompt via env
ANKI_EXTRACT_FORCE=1 python anki_apkg_extract.py
```
## Output
```text
/
notes.csv # UTF-8 with Anki import hints
medias/ # reconstructed media files
templates/ # CSS + per-template HTML
```
## Notes
- 2.1/2.0 work with stdlib only.
- 2.1b requires zstandard + protobuf.
## Acknowledgments
Thanks to Telegram user `@KarasawaKoko` for contributing portions of this project.
## License
MIT