Anki ↔ Markdown, with bidirectional sync, custom note types, and LLM integration
Project description
AnkiOps
AnkiOps is a bidirectional Anki ↔ Markdown bridge where each deck becomes a Markdown file. Edit in plain text, version with Git, enhance with LLMs, and sync changes both ways.
Features
- Full Anki support: Safe, performant bidirectional syncing of notes with custom note types, (sub-)decks, and media files
- Markdown-first: Edit in your favourite editor and render Markdown features in Anki (including syntax highlighting)
- Simple CLI interface for importing and exporting between Anki and the filesystem
- LLM-integration: Run programmable tasks such as content review, grammar fixes, or translations on your collection
- Git-based: Share your decks and collaborate via fully-synchronized Github repositories (nyi)
[!NOTE] AnkiOps only acts on note types defined within the
note_types/folder. You can add note types from Anki usingankiops note-types --add <name>.
Installation
- Install AnkiOps via pipx: Pipx will make AnkiOps globally available in your terminal.
pipx install ankiops
- Initialize AnkiOps: Make sure that Anki is running, with the AnkiConnect add-on enabled. Initialize AnkiOps in any empty directory of your choosing. The command creates a database file for synchronization, an
llm/directory for custom LLM tasks, and anote_types/directory for the note types AnkiOps will act on (following Infrastructure as Code principles). The additional tutorial flag creates a sample Markdown deck you can experiment with.
ankiops init --tutorial
- Execute AnkiOps: Import the tutorial deck into Anki using:
ankiops ma # alias for markdown-to-anki (import)
- Keep everything in sync: When editing your Markdown files, sync Markdown → Anki (and vice versa), as each sync makes one side match the other. After reviewing and editing your cards in Anki, you can sync Anki → Markdown using the following command:
ankiops am # alias for anki-to-markdown (export)
FAQ
How is this different from other Markdown tools?
Most available tools are one-way importers: you write in Markdown and push to Anki, but edits in Anki don't sync back. AnkiOps is bidirectional: you can edit in either Anki or Markdown and sync in both directions. It uses a one-file-per-deck structure, making your collection easier to navigate than approaches that use one file per card. Further, custom note types are supported while maintaining a clear working environment. This essentially lets you manage your entire Anki collection from your favorite text editor.
Is it safe to use?
Yes, AnkiOps will never modify notes that are not defined within the note_types/ folder. Your existing collection won't be affected and you can safely mix managed and unmanaged notes within one deck. Further, AnkiOps only syncs if the activated profiles matches the one it was initialized with. Concerning the Markdown files, AnkiOps automatically creates a Git commit of your collection folder before every sync, so you can always roll your files back if needed.
How do I create new notes?
Create a new Markdown file in your initialized AnkiOps folder. For the first import, the file name acts as the deck name. Subdecks use __ (for example, Anatomy::Heart --> Anatomy__Heart.md). Notes must be separated by a new line, three dashes ---, and another new line. You can add new notes anywhere in an existing file.
<!-- note_key: 123487556abc -->
Q: Question text here
A: Answer text here
E: Extra information (optional)
M: Content behind a "more" button (optional)
---
<!-- note_key: 123474567def -->
T: Text with {{c1::multiple}} {{c2::cloze deletions}}.
E: Some *formatted* extra info.
{width=700}
---
Q: What is this?
C1: A multiple choice note
C2: with
C3: automatically randomized answers.
A: 1, 3
In this example, the last note is a new note which will get a note_key comment assigned on the next import.
How are different note types handled?
AnkiOps reads note types exclusively from your local note_types/ directory. ankiops init ejects default note types as bootstrap files; those local files are then the only source of truth and can be modified as needed. Each note type is identified by a unique set of field labels. These labels are defined innote_types/name/note_type.yaml and can be customized as needed. The set operations of each unique note type are defined by the identifying fields in the yamls. For an overview of the current configuration, use ankiops note-types.
How can I migrate my existing notes into AnkiOps?
There are three ways to migrate your existing collection.
You can create new note types configuration files in the note_types/ folder that match your existing note types in Anki by hand, use the ankiops note-types --add <name> command to copy note types from Anki, or convert your existing notes to the default AnkiOps note types using Change Note Type… in the Anki browser.
For the last option specifically, the recommended workflow is:
- Convert your existing notes to the matching AnkiOps note types via
Change Note Type…in the Anki browser. - Export your notes from Anki to Markdown using
ankiops am. - In the first re-import, some formatting may change because the original HTML from Anki may not follow the CommonMark standard. Formatting of your cards can be done automatically at a low cost using the included JSON serializer and AI tooling.
How does it work?
AnkiOps assigns a stable note_key to each managed note. It is represented by a single-line HTML tag (e.g., <!-- note_key: a1b2c3d4e5f6 -->) above a note in the Markdown. AnkiOps note keys are profile-independent, in contrast to Anki's note IDs. One AnkiOps folder represents one Anki profile. The .ankiops.dbdatabase stores the mapping between Anki's note IDs and AnkiOps note keys, along with other metadata. When syncing, AnkiOps uses these note keys to determine which notes to create, update, or delete in either Anki or Markdown. Media files are stored in a media/ folder with hashed file names to avoid conflicts.
What is the recommended workflow?
We recommend using VS Code. It has excellent AI integration, a native Markdown previewer, and supports image pasting from the clipboard directly into the /media folder (automatically set up).
How can I share my AnkiOps collection?
TODO
How do I upgrade AnkiOps to the latest version?
Use pipx upgrade ankiops to upgrade AnkiOps to the latest version. Delete all local AnkiOps files (except for your Markdown decks), re-initialize AnkiOps in the same folder using ankiops init, and sync from Anki via ankiops am. Since all files are git-tracked, you can easily spot any changes and roll back if needed.
How can I develop AnkiOps locally?
Fork this repository and initialize the tutorial in your root folder (make sure Anki is running). This will create a folder called collection with the sample Markdown in it. Paths will adapt automatically to the development environment. You can run AnkiOps locally using the main script.
git clone https://github.com/visserle/ankiops.git
cd ankiops
uv sync
uv run python -m main init --tutorial
uv run python -m main ma
Are Pull Requests welcome?
Yes! We welcome contributions of all kinds, including bug fixes, new features, documentation improvements, and more. Please open an issue or submit a pull request if you'd like to contribute.
What commands and flags are available in the CLI?
Global:
--debug- Enable debug logging--version- Show installed AnkiOps version--help- Show help message
init:
--tutorial- Create tutorial markdown file
anki-to-markdown / am:
--no-auto-commit,-n- Skip automatic git commit
markdown-to-anki / ma:
--no-auto-commit,-n- Skip automatic git commit
serialize:
--output,-o- Output file path (default:<collection-name>.json)--deck- Serialize only one deck (includes subdecks by default)--no-subdecks- With--deck, exclude subdecks (exact deck only)
deserialize:
--input,-i- Input file path (default:<collection-name>.json)--overwrite- Overwrite existing markdown files
llm:
ankiops llm- Show LLM status dashboard (tasks + recent jobs)ankiops llm <task_name> [--model <model>] [--deck <deck_name>]- Plan one configured taskankiops llm <task_name> --run [--model <model>] [--deck <deck_name>] [--no-auto-commit]- Run one configured task jobankiops llm --job <job_id|latest>- Show one LLM job in detail
note-types:
ankiops note-types- Show note types, identifying labels, and the label registryankiops note-types --add <name>- Copy a note type from Anki into localnote_types/with interactive label/identifying prompts
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ankiops-0.5.9.tar.gz.
File metadata
- Download URL: ankiops-0.5.9.tar.gz
- Upload date:
- Size: 101.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fffd343f3222b01cb6064a73282a1acae2b4757d197fd2091788a3183f124221
|
|
| MD5 |
bb60c9c66bec9c960d69a56094cb0116
|
|
| BLAKE2b-256 |
84ea83b4ced629883ab4d1e7a5f76d9563b62b0fc5f7e357f67adbc497c9234a
|
Provenance
The following attestation bundles were made for ankiops-0.5.9.tar.gz:
Publisher:
publish.yml on visserle/AnkiOps
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ankiops-0.5.9.tar.gz -
Subject digest:
fffd343f3222b01cb6064a73282a1acae2b4757d197fd2091788a3183f124221 - Sigstore transparency entry: 1520233190
- Sigstore integration time:
-
Permalink:
visserle/AnkiOps@c1c03c086e4285efae1a5ca8333851250a501346 -
Branch / Tag:
refs/tags/v0.5.9 - Owner: https://github.com/visserle
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c1c03c086e4285efae1a5ca8333851250a501346 -
Trigger Event:
release
-
Statement type:
File details
Details for the file ankiops-0.5.9-py3-none-any.whl.
File metadata
- Download URL: ankiops-0.5.9-py3-none-any.whl
- Upload date:
- Size: 121.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c93584e3a40406d007a2e9cfd2ec822df62915a39d6dfee2fc2f915c96ea300b
|
|
| MD5 |
c2e1351b95d3ef30279fe3788ddd1ca7
|
|
| BLAKE2b-256 |
631355913f99f47b8ea7d0a3e251741cf8fd8d9905d6c94492fb5e4a4a2b0d90
|
Provenance
The following attestation bundles were made for ankiops-0.5.9-py3-none-any.whl:
Publisher:
publish.yml on visserle/AnkiOps
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ankiops-0.5.9-py3-none-any.whl -
Subject digest:
c93584e3a40406d007a2e9cfd2ec822df62915a39d6dfee2fc2f915c96ea300b - Sigstore transparency entry: 1520233321
- Sigstore integration time:
-
Permalink:
visserle/AnkiOps@c1c03c086e4285efae1a5ca8333851250a501346 -
Branch / Tag:
refs/tags/v0.5.9 - Owner: https://github.com/visserle
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c1c03c086e4285efae1a5ca8333851250a501346 -
Trigger Event:
release
-
Statement type: