- The files must be plain text (myfile.txt). Other formats like myfile.xls, myfile.rtf, myfile.doc must be saved as a plain text file first.
- The files must be in UTF-8 format (see below).
- Anki determines the number of fields in the file by looking at the first (non-commented) line. If some of the later records in the file contain fewer fields, Anki will treat the missing fields as if they were blank. If some of your records contain extra fields, the extra content will not be imported.
- Anki tries to guess which field separator (commas, tabs, etc.) your file uses. If it guesses wrongly, you can change it in the import options window and preview the results. Or you can add file headers to force a specific field separator.
Spreadsheets and UTF-8
If you have non-Latin characters in your file (such as accents, Japanese and so on), Anki expects files to be saved in a “UTF-8 encoding”. The easiest way to do this is to use the free LibreOffice spreadsheet program instead of Excel to edit your file, as it supports UTF-8 easily, and also exports multi-line content properly, unlike Excel. If you wish to keep using Excel, please see this doc for more information. To save your spreadsheet to a file Anki can read with LibreOffice, go to File > Save As, and then select CSV for the type of file. After accepting the default options, LibreOffice will save the file and you can then import the saved file into Anki.HTML
Anki can treat text imported from text files as HTML (the language used for web pages). This means that text with bold, italics and other formatting can be exported to a text file and imported again. If you want to include HTML formatting, you can check the “allow HTML in fields” checkbox when importing. You may wish to turn this off if you’re trying to import cards whose content contains angle brackets or other HTML syntax. If you wish to use HTML for formatting your file but also wish to include angle brackets or ampersands, you may use the following replacements:| Character | Replacement |
|---|---|
| < | < |
| > | > |
| & | & |
Importing Media
If you want to include audio and pictures from a text file import, copy the files into the collection.media folder. Do not put subdirectories in the media folder, or some features will not work. After you’ve copied the files, change one of the fields in your text file as follows.Bulk Media
Another option for importing large amounts of media at once is to use the media import add-on. This add-on will automatically create notes for all files in a folder you select, with the filenames on the front (minus the file extension, so if you have a file named apple.jpg, the front would say “apple”) and the images or audio on the back. If you would like a different arrangement of media and filenames, you can change the note type of the created cards afterwards.Duplicates and Updating
When importing text files, Anki uses the first field to determine if a note is unique. By default, if the file you are importing has a first field that matches one of the existing notes in your collection and that existing note is the same type as the type you’re importing, the existing note’s other fields will be updated based on content of the imported file. A drop-down box in the import screen allows you to change this behaviour, to either ignore duplicates completely, or import them as new notes instead of updating existing ones. The match scope setting controls how duplicates are identified. When note type is selected, Anki will identify a duplicate if another note with the same note type has the same first field. When set to note type and deck, a duplicate will only be flagged if the existing note also happens to be in the deck you are importing into. If you have updating turned on and older versions of the notes you’re importing are already in your collection, they will be updated in place (in their current decks) rather than being moved to the deck you have set in the import dialog. If notes are updated in place, the existing scheduling information on all their cards will be preserved. For info on how duplicates are handled in .apkg files, please see the Deck Packages section.File Headers
Anki 2.1.54+ supports certain headers that can be included in the text file to make importing more powerful or convenient. They consist of#key:value pairs
and must be listed in separate lines at the top of the file.
| Key | Allowed Values | Behaviour |
|---|---|---|
separator | Comma, Semicolon, Tab, Space, Pipe, Colon, or the corresponding literal characters | Determines the field separator. |
html | true, false | Determines whether the file is treated as HTML. |
tags | List of tags, separated by spaces | Adds the listed tags to every imported note. |
columns | List of names, separated by the previously set separator | Determines the number of columns and shows their given names when importing. |
notetype | Note type name or id | Presets the note type, if it exists. |
deck | Deck name or id | Presets the deck, if it exists. |
notetype column | 1, 2, 3, … | Determines which column contains the note type name or id of each note, see Notetype Column. |
deck column | 1, 2, 3, … | Determines which column contains the deck name or id of each note, see Deck Column. |
tags column | 1, 2, 3, … | Determines which column contains the tags of each note. |
guid column | 1, 2, 3, … | Determines which column contains the GUID of each note, see GUID Column. |
Notetype Column
Usually, all notes from a file will be mapped to a single note type. That changes, if there is a column with note type names or ids. This allows you to import notes with different note types, and their fields will be mapped implicitly: The first regular column is used for the first field of any note regardless of its note type, the second regular column for the second field, and so on. A regular column here being a column that does not contain special information like decks, tags, note types or GUIDs.Deck Column
Usually, any new cards created as a result of importing a text file will be placed in a single deck of your choice. If the file contains a deck column, however, new cards of a note will be placed in its specified deck instead. If the deck does not exist, a deck with the given name will be created.GUID Column
GUID stands for Globally Unique Identifier. When you create notes in Anki, Anki assigns each note a unique ID, which can be used for duplicate checking. If you export your notes with the GUID included, you can make changes to the notes, and as long as you do not modify the GUID field, you’ll be able to import the notes back in to update the existing notes. Please note that the GUID is intended to be created by Anki. If you are creating your own IDs, such asMYNOTE0001, then it’s recommended that you place the IDs
in the first field, instead of assigning them to Anki’s internal GUID. When importing,
Anki is able to use either the first field or the GUID for duplicate checking, so you do not
need to make IDs a GUID in order to be able to update your notes.
One other thing to note is that the duplicate option will not work for rows that have a
non-empty GUID. If a GUID is provided, and already exists in the collection, a duplicate will
not be created.