Save as SingleFile.html | Input Folder | Output Folder |
---|---|---|
leetcode.com/problem-x | SingleFile.html | anki_deck.apkg |
Export your LeetCode solutions into personalized Anki flashcards, deliberately designed to reinforce your unique problem-solving approaches.
By exporting HTMLs of solved problems into structured flashcards with the problem on the front and your specific solution on the back, you create a personalized learning system that strengthens your distinctive problem-solving style.

- Complete HTML to Anki Conversion: Transforms saved LeetCode pages into ready-to-import Anki packages
- Image Preservation: Maintains diagrams and illustrations from problem descriptions
- Batch Processing: Process multiple problems at once by adding HTML files to the input folder
- Incremental Updates: Adding new problems only creates cards for content not already in your Anki collection
- Theme Support: Cards automatically adapt to Anki's light/dark theme settings for comfortable studying in any environment
- Debug Mode: Detailed logging with
-debug
flag to troubleshoot extraction issues
Option 1: Local Installation - Click to expand
-
Clone this repository:
git clone https://github.com/npcnixel/leetcode-to-anki-go.git cd leetcode-to-anki-go
-
Run the application:
go run main.go
Option 2: Docker (recommended for Windows users) - Click to expand
-
Install Docker Desktop
-
Clone this repository:
git clone https://github.com/npcnixel/leetcode-to-anki-go.git cd leetcode-to-anki-go
-
Build the Docker image:
docker build -t leetcode-to-anki-go .
-
Run the container:
# For macOS/Linux: docker run --rm -v "$(pwd)/input:/app/input" -v "$(pwd)/output:/app/output" leetcode-to-anki-go # For Windows CMD: docker run --rm -v "%cd%/input:/app/input" -v "%cd%/output:/app/output" leetcode-to-anki-go # For Windows PowerShell: docker run --rm -v "${PWD}/input:/app/input" -v "${PWD}/output:/app/output" leetcode-to-anki-go
-
The output will be available in the
output
directory, just as with the local installation
-
Save LeetCode Problems:
- LeetCode uses GraphQL which means standard browser "Save as" (Ctrl+S/Cmd+S) might not capture all content.
βΌοΈ Use a browser extension like SingleFile to capture the fully rendered page with all contentβΌοΈ
-
Prepare Input Files:
- Place all saved HTML files in the
input
directory
- Place all saved HTML files in the
-
Generate Anki Cards:
- Run the application from the command line:
go run main.go
- Run the application from the command line:
-
Import into Anki:
- Locate the generated
.apkg
file in theoutput
directory - Open Anki and select "File > Import" (or press Ctrl+Shift+I / Cmd+Shift+I)
- Select the
.apkg
file and click "Open" - The cards will be added to your Anki collection
Note: Only new problems will be added as cards. If you've previously imported some problems, they won't be duplicated.
- Locate the generated
- Saved single-file HTML files are parsed to extract problem titles, descriptions, and your solutions
- Content is parsed with proper styling for readability
- Anki deck is created with cards that have the problem on the front and your solution on the back
- Everything is packaged into a standard Anki package (
.apkg
) format
input/
: Place saved LeetCode HTML files hereoutput/
: Generated Anki package will be saved here
This tool heavily relies on genanki-go for comprehensive ANKI deck construction, complete customization and professional flashcard generation in Go with full control over deck structure and formatting.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.