💻 Leetcode Study Tool
This package lets you get grokking as quickly as possible with Leetcode. It provides a command-line tool for interracting with Leetcode to create either an Excel file or Anki flashcards for study. Currently, this tool supports taking in a list of leetcode question slugs or URLs or popular study sets (including the Blind 75, Grind 75, and Neetcode 150).
🤔 Why?
This package was created as an opinionated alternative to other existing packages (as listed at the bottom of this README).
📥 Installation
$ pip install leetcode-study-tool
💻 Usage
usage: leetcode-study-tool [-h] (--url URL | --file FILE | --preset {blind_75,grind_75,grind_169,neetcode_150,neetcode_250,neetcode_all}) [--format {anki,excel}]
[--template TEMPLATE] [--csrf CSRF] [--output OUTPUT] [--language LANGUAGE] [--include-code]
Generates problems from LeetCode questions in a desired format.
options:
-h, --help show this help message and exit
--url URL, -u URL The URL(s) or slug(s) of the LeetCode question(s) to generate problem(s) for. (default: None)
--file FILE, -f FILE The file containing the URL(s) or slug(s) of the LeetCode question(s) to generate problem(s) for. (default: None)
--preset {blind_75,grind_75,grind_169,neetcode_150,neetcode_250,neetcode_all}, -p {blind_75,grind_75,grind_169,neetcode_150,neetcode_250,neetcode_all}
The preset to use to generate problem(s) for. (default: None)
--format {anki,excel}, -F {anki,excel}
The format to save the Leetcode problem(s) in. (default: anki)
--template TEMPLATE, -t TEMPLATE
Path to a custom Jinja template file for rendering problems. (default: None)
--csrf CSRF, -c CSRF The CSRF token to use for LeetCode authentication. (default: None)
--output OUTPUT, -o OUTPUT
The output file to write the problem(s) to. (default: output.txt)
--language LANGUAGE, -l LANGUAGE
The language to generate problem(s) for. (default: None)
--include-code, -ic Include solution code from NeetCode GitHub repository using the specified language. (default: False)
💡 Example
In the simplest case, if you want to Grok the most commonly asked questions, you should generate from a preset. For example, generating Anki cards from the Grind 75 is as simple as
$ leetcode-study-tool -p grind_75
Perhaps, instead, you'd prefer to import questions that you've already worked on. In a directory with a file named questions.txt, where each line is either a Leetcode problem URL or slug (or a combination of both), we can run the command
$ leetcode-study-tool -f questions.txt
which will generate the file output.txt. We can then open Anki to import these problems as demonstrated below, ensuring to select semicolon as a field separator.
Including Solution Code
You can include solution code from the NeetCode GitHub repository by using the --include-code flag along with specifying a programming language:
$ leetcode-study-tool -p grind_75 --language python --include-code
This will fetch solution code in the specified language (when available) and include it in your Anki cards or Excel output.
Supported languages include: c, cpp, csharp, dart, go, java, javascript, kotlin, python, ruby, rust, scala, swift, and typescript.
📒 Anki
When generating an Anki output, the resulting "cards" are saved as a .txt file. These cards include three fields:
- The front of the study card, containing the question ID, Title, URL, and problem description
- The publicly available solutions (and NeetCode solution or code, if available)
- The tags associated with the problem (i.e., if the problem involves a hash map, arrays, etc...)
📊 Excel
When generating an Excel output, the resulting questions are saved in an .xlsx file. Each problem includes the following fields:
- ID of the leetcode question
- Title of the leetcode question
- URL of the leetcode question
- Last date that this question was attempted by the user (please note that this is not pulled from your leetcode profile, but left for you to update as you progress in solving leetcode questions)
- The tags associated with the problem (i.e., if the problem involves a hash map, arrays, etc...)
- Neetcode video link (if it exists)
- Solution links for the problem (if they are reachable)
- Companies that have asked this question recently in interviews (if they are reachable)
Custom Templates
LeetCode Study Tool supports custom Jinja2 templates for generating Anki cards or other outputs. You can specify your own template file using the --template flag:
leetcode-study-tool --url "https://leetcode.com/problems/two-sum/" --template "path/to/my_template.jinja"
Template Variables
When creating your custom template, the following variables are available:
| Variable | Description |
|---|---|
url |
The URL to the LeetCode problem |
slug |
The problem slug |
data |
Object containing all problem data |
data.id |
Problem ID |
data.title |
Problem title |
data.content |
Problem description (HTML) |
data.difficulty |
Problem difficulty (Easy, Medium, Hard) |
data.tags |
List of topic tags for the problem |
data.companies |
List of companies that ask this problem |
data.solutions |
List of available solutions on LeetCode |
data.neetcode_solution |
NeetCode solution code (if --include-code is used) |
data.language |
Language of the solution code |
neetcode |
NeetCode video information (when available) |
Solution Code Example
Here's an example template that highlights the solution code:
<h1>{{ data.id }}. {{ data.title }} ({{ data.difficulty }})</h1>
<div class="content">
{{ data.content }}
</div>
<div class="tags">
{% for tag in data.tags %}
<span class="tag">{{ tag.name }}</span>
{% endfor %}
</div>
;
{% if data.neetcode_solution %}
<h3>Solution Code ({{ data.language }})</h3>
<pre><code>
{{ data.neetcode_solution }}
</code></pre>
{% endif %}
{% if data.solutions %}
<div class="community-solutions">
<h3>Community Solutions:</h3>
<ul>
{% for solution in data.solutions[:3] %}
<li><a href="{{ solution_url(slug, solution.id) }}">Solution {{ loop.index }}</a></li>
{% endfor %}
</ul>
</div>
{% endif %}
;
{{ data.tags|map(attribute='slug')|join(' ') }}
🛠 Development
For developers who want to contribute to this project, we use UV for dependency management:
Setup with UV
# Install UV (if not already installed)
curl -LsSf https://astral.sh/uv/install.sh | sh
# Clone and setup the project
git clone https://github.com/johnsutor/leetcode-study-tool.git
cd leetcode-study-tool
uv sync --dev
Development Commands
# Format code
make format
# Check formatting
make format-check
# Run tests
make test
# Type checking
make type-check
# Sync dependencies
make sync
# Install only main dependencies
make install
Using UV Directly
# Add a new dependency
uv add package-name
# Add a development dependency
uv add --dev package-name
# Run any command in the project environment
uv run python leetcode_study_tool/cli.py --help
# Update lockfile
uv lock
🛣 Roadmap
- Use TQDM to show card generation progress
- Add support for exporting to an excel sheet
- Add support for showing neetcode solutions on the back of the card as a
- Add support for getting the difficulty of questions
- Add support for Jinja templating formatters
- Add support for including NeetCode solution code
- Migrate to UV for faster dependency management
- Add NeetCode shorts
- Reach 90% test coverage
- Add support for fetching premium questions via authentification
- Add support for importing cards into Quizlet
- Add support for fetching questions by topic or tag link
🔎 Other Usefull Stuff
Metadata
Release files for leetcode-study-tool 1.3.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| leetcode_study_tool-1.3.7.tar.gz | 51.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| leetcode_study_tool-1.3.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 92.8 kB
Release files / leetcode_study_tool-1.3.7.tar.gz
| Download URL | leetcode_study_tool-1.3.7.tar.gz |
|---|---|
| Size | 51.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
610d2f4ca9eb9efe8c1a5591afd27f37c0a82c48661526319240e93a11382e54
|
|
BLAKE2b-256 checksum How to use checksums |
98c5f55644272b392622bcccc097593caac8076e82a0b4cb5c5e267992b472ef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 8, 2026.
Transparency logRelease files / leetcode_study_tool-1.3.7-py3-none-any.whl
| Download URL | leetcode_study_tool-1.3.7-py3-none-any.whl |
|---|---|
| Size | 41.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
17ce9691b07becc3d147db704c309dcb1235294a5a7235ebd2d0a99649b0216a
|
|
BLAKE2b-256 checksum How to use checksums |
9df30c9e1be8f9f3c4d89faf529527ecf26632b04c784653ca8c6f3251430640
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 8, 2026.
Transparency log