A CLI tool to bi-directionally sync Anki notes as YAML files
Project description
Anki YAML Sync
A Python CLI tool for bi-directional syncing of Anki notes as YAML files for easy editing and version control.
Inspired by visserle/DeckOps.
Features
- Bi-Directional Syncing: Import notes from Anki to YAML and export YAML back to Anki
- Human-Readable Format: Notes are stored as YAML files for easy editing
- Flexible: Update existing notes or create new notes (based on ID field)
- Deck-Aware Storage: Notes are stored in folders that mirror deck nesting
Requirements
- Anki: Running instance of Anki desktop
- AnkiConnect: Must be installed and running on
localhost:8765(default)
To set up AnkiConnect (https://ankiweb.net/shared/info/2055492159):
- Open Anki > Menu Bar > Tools > Add-ons > Get Add-ons
- Enter the code
2055492159and click "OK" to install AnkiConnect - Restart Anki
Installation
Run the following command to install globally: pipx install anki-yaml-sync
Usage
Import Notes from Anki
Fetch all notes from Anki and save them as YAML files:
anki-yaml-sync import [--output-dir OUTPUT]
Aliases: get-from-anki, fetch, gfa, f
Options:
--output-dir,-o: Directory to save YAML files (default:notes)
Example:
anki-yaml-sync import --output-dir ./my-notes
Export Notes to Anki
Sync YAML files back to Anki:
anki-yaml-sync export [--input-dir INPUT] [--deck DECK]
Aliases: send-to-anki, push, sta, p
Options:
--input-dir,-i: Directory containing YAML files (default:notes)--deck: Deck to add new notes to (default:Default)
Example:
anki-yaml-sync export --input-dir ./my-notes --deck "My Deck"
Verbose Output
Add -v or --verbose flag to any command for detailed logging:
anki-yaml-sync -v import
anki-yaml-sync -v export
YAML Format
Each note is stored as a separate YAML file. Example:
id: 1234567890
type: Basic
deck: Languages::French
tags:
- french
- vocabulary
fields:
Front: Bonjour
Back: Hello
Fields:
id: Anki note ID (required for updates)type: Note type name (e.g., "Basic", "Cloze")deck: Full deck name using::(e.g.,Parent::Child)tags: List of tags to applyfields: Dictionary of field names to field values
Deck Folder Structure
Deck nesting is reflected in folders. For example, a note in deck Languages::French is stored as:
notes/Languages/French/<note>.yaml
Workflow
- Initial Import: Run
anki-yaml-sync importto create YAML files from your Anki collection - Edit: Open and edit the YAML files with your text editor or IDE
- Sync Back: Run
anki-yaml-sync exportto sync your changes back to Anki
Updating Existing Notes
If a YAML file has an id field that matches an existing Anki note, the export will update that note. Fields are completely replaced (not merged).
If the YAML deck differs from the current deck, the note's cards will be moved to the YAML deck.
Creating New Notes
To create a new note:
- Create a new YAML file with a temporary or missing
id(e.g.,0ornull) - Run
anki-yaml-sync export - The YAML file will be automatically updated with the assigned note ID
Note: If the ID is that of an existing note, the existing note may be overwritten with the YAML file instead of creating a new note in Anki.
Contributing
See CONTRIBUTING.md for guidelines on contributing to this project and setting up development environment on your device.
Project details
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 anki_yaml_sync-0.2.2.tar.gz.
File metadata
- Download URL: anki_yaml_sync-0.2.2.tar.gz
- Upload date:
- Size: 14.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
082f7aa57ab537315ada92eea2e9ed0b20ce76801bdb5a2a7881487dbea000e9
|
|
| MD5 |
9ff89a18f7ce0651b8a42acd3fa32dbc
|
|
| BLAKE2b-256 |
972790d394b58f31377b2c13922503ddd828f44f2ae2066f113eecf5e3a181e8
|
Provenance
The following attestation bundles were made for anki_yaml_sync-0.2.2.tar.gz:
Publisher:
python-publish.yml on danielh-official/anki-yaml-sync
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
anki_yaml_sync-0.2.2.tar.gz -
Subject digest:
082f7aa57ab537315ada92eea2e9ed0b20ce76801bdb5a2a7881487dbea000e9 - Sigstore transparency entry: 952318420
- Sigstore integration time:
-
Permalink:
danielh-official/anki-yaml-sync@c40cb6651c5a2a11016c58760d8d356324a2348d -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/danielh-official
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@c40cb6651c5a2a11016c58760d8d356324a2348d -
Trigger Event:
release
-
Statement type:
File details
Details for the file anki_yaml_sync-0.2.2-py3-none-any.whl.
File metadata
- Download URL: anki_yaml_sync-0.2.2-py3-none-any.whl
- Upload date:
- Size: 14.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
213ab50d47264f1fd044ed76f8b306d9d613a25f186f21da3d2f4d2979c53195
|
|
| MD5 |
bb4fa0222819a60bfad5061dd68318c7
|
|
| BLAKE2b-256 |
0e6e334a99d5ca7e2a05219e81a832d94a83f9f938ab8c226fb0399c2c26e402
|
Provenance
The following attestation bundles were made for anki_yaml_sync-0.2.2-py3-none-any.whl:
Publisher:
python-publish.yml on danielh-official/anki-yaml-sync
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
anki_yaml_sync-0.2.2-py3-none-any.whl -
Subject digest:
213ab50d47264f1fd044ed76f8b306d9d613a25f186f21da3d2f4d2979c53195 - Sigstore transparency entry: 952318421
- Sigstore integration time:
-
Permalink:
danielh-official/anki-yaml-sync@c40cb6651c5a2a11016c58760d8d356324a2348d -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/danielh-official
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@c40cb6651c5a2a11016c58760d8d356324a2348d -
Trigger Event:
release
-
Statement type: