An .apkg file is an Anki deck package. Anki, the open-source spaced-repetition flashcard app, uses it to move decks between computers and phones and to share them with other people. If someone sent you one, or you downloaded a shared deck from AnkiWeb, it holds a deck's notes, card layouts and media, and optionally its review history.
What's inside an .apkg
An .apkg is a zip archive. Rename a copy to .zip and you can open it with any unzip tool. Inside you'll find some of these:
| File | What it is |
|---|---|
collection.anki21b | The deck as an SQLite database, compressed with zstd. Written by Anki 2.1.50 and later. |
collection.anki21 | The same, uncompressed, in the older 2.1 layout. Written when “Support older Anki versions” is ticked. |
collection.anki2 | The original layout. New exports put a placeholder here that only says to update Anki. |
media | A list mapping numbered files to their real names (JSON in older exports, compressed binary in newer ones). |
0, 1, 2, … | The images and sounds themselves, renamed to numbers. |
meta | A few bytes saying which version wrote the package. |
Inside the database, each note holds the text of its fields, separated by an invisible character, plus its tags. Each note has a note type (Basic, Cloze, or a custom one) that lists its fields and the card templates, written in HTML and CSS, which turn one note into one or more cards. Cards record which deck they belong to and, if scheduling was exported, when they're due next.
.apkg vs .colpkg
An .apkg holds one deck (and its subdecks), meant to be added to someone's existing collection. A .colpkg is a backup of a whole Anki profile, every deck at once, and importing it replaces the collection on that device. Never import someone else's .colpkg into your own Anki unless you mean to swap out all your decks. Internally they use the same format.
How to open an .apkg file
- Anki Desktop (Windows, macOS, Linux; free): double-click the file, or use File → Import.
- AnkiDroid (Android; free): open the file from your downloads, or use Import in the deck list menu.
- AnkiMobile (iPhone and iPad; paid): open the file in the Files app and share it to AnkiMobile.
- AnkiWeb can't import files. Import on a device, then sync.
Reading an .apkg without Anki
Sometimes you just want to see what's in a deck, or get the cards into a spreadsheet, without installing anything. The APKG to CSV converter does that in a browser tab, on a phone or a computer. It unzips the package, decompresses the collection, reads every note type and writes a table with the field names as headers. It also exports to Excel and TSV, and can open the cards straight in iLoveFlashcards to study. Nothing is uploaded.
If you're technical: unzip the file, and if the collection starts with the bytes 28 B5 2F FD it's zstd-compressed, so run zstd -d on it first. Then any SQLite browser opens it; the notes are in the notes table, with fields separated by the character 0x1F. In 2.1.50+ files some tables use a custom unicase collation that only Anki defines, so tools other than Anki may refuse some queries until the schema is patched.
Is an .apkg file safe?
It can't run anything on its own, but card templates are HTML and may contain JavaScript, which runs inside Anki when cards are shown. Decks from AnkiWeb's shared list and from people you know are normally fine. If a deck is from a stranger, converting it to a spreadsheet first lets you read every card without running its templates.
Making an .apkg
In Anki, use File → Export and choose Anki Deck Package (.apkg). Without Anki, you can build one from a list: the CSV to APKG and Excel to APKG converters make a deck that imports on every Anki app, with your column names as fields. And if you're sharing with people who don't use Anki at all, an iLoveFlashcards share link or .ilfc file opens in any browser.