leetcode-exporter
v0.3.1
Published
Open LeetCode problems in your editor and test/submit from CLI
Maintainers
Readme
LeetCode Exporter
Open LeetCode problems in your editor and test/submit solutions from the command line.
Quick Start
npm install -g leetcode-exporter
leetcode-exporter setupThen load the Chrome extension and register it (see Installation for details).
Features
- One-Click Export: Click extension icon on any LeetCode problem to open it in your editor
- CLI Test & Submit: Run tests and submit solutions without leaving your terminal
- No Browser Required: After opening a problem, work entirely from your editor
- Multiple Languages: JavaScript, TypeScript, Python, Java, C++, C, Go, Rust, and more
Installation
Prerequisites
- Node.js 14 or higher
- Google Chrome browser
- One of: Cursor, VS Code Insiders, or VS Code
Step 1: Install the CLI Tool
npm install -g leetcode-exporterStep 2: Run Setup
leetcode-exporter setupThis will register the native host and open Chrome's extensions page.
Step 3: Load the Extension
- In Chrome, enable Developer mode (toggle in top-right)
- Click Load unpacked
- Paste the path from clipboard (or navigate to the extension folder)
Step 4: Register Extension
- Click the extension icon in Chrome toolbar
- Click "Copy Command"
- Paste and run in terminal
Usage
Opening Problems
- Go to any LeetCode problem (e.g., https://leetcode.com/problems/two-sum/)
- Click the extension icon → "Open in Editor"
- The problem opens in your editor with the code template and description
Testing Solutions
# Test solution in current directory
leetcode-exporter test
# Test specific problem
leetcode-exporter test ./1-two-sumSubmitting Solutions
# Submit solution in current directory
leetcode-exporter submit
# Submit specific problem
leetcode-exporter submit ./1-two-sumExample output:
Submitting: /Users/you/leetcode/1-two-sum/solution.py
Problem: two-sum (#1)
Language: python3
Submitting...
✓ Accepted
Runtime: 52 ms (faster than 85.2%)
Memory: 15.1 MB (less than 62.3%)
Tests: 63/63 passedConfiguration
# View current config
leetcode-exporter config
# Change workspace directory
leetcode-exporter config workspaceDir ~/projects/leetcode
# Set preferred editor (auto, cursor, code-insiders, code)
leetcode-exporter config editor cursor
# Enable visual button on LeetCode pages (optional)
leetcode-exporter config showVisualButton trueFile Output
Files are saved to ~/leetcode/ in organized directories:
~/leetcode/
├── 1-two-sum/
│ └── solution.js
├── 2-add-two-numbers/
│ └── solution.py
└── 3-longest-substring-without-repeating-characters/
└── solution.rsExample file content:
/*
* Problem: Two Sum
* Difficulty: Easy
* URL: https://leetcode.com/problems/two-sum/
*
* Description:
* Given an array of integers nums and an integer target, return indices
* of the two numbers such that they add up to target...
*/
function twoSum(nums, target) {
// Your solution here
}Supported Languages
| Language | Extension | |----------|-----------| | JavaScript | .js | | TypeScript | .ts | | Python | .py | | Java | .java | | C++ | .cpp | | C | .c | | Go | .go | | Rust | .rs | | Ruby | .rb | | Swift | .swift | | Kotlin | .kt |
Uninstall
leetcode-exporter uninstallThen remove the extension from Chrome.
Troubleshooting
"Not logged in" error when testing/submitting
- Make sure you're logged in to LeetCode in Chrome
- Visit any LeetCode problem page (this syncs your session to the CLI)
- Try the command again
"No editor found" error
- Make sure you have VS Code, VS Code Insiders, or Cursor installed
- Ensure your editor's CLI is in PATH:
which code # or code-insiders, or cursor - Or set your preferred editor:
leetcode-exporter config editor cursor
Extension icon doesn't open problem
- Make sure you're on a LeetCode problem page (e.g., /problems/two-sum/)
- Try refreshing the page
- Check that the extension is enabled in
chrome://extensions
Native host errors
Re-run the setup:
leetcode-exporter setupSecurity & Privacy
- Session-based auth: Uses your existing LeetCode browser session for API calls
- Local storage: Session tokens are stored locally in
~/.leetcode-exporter.json - No external servers: All communication is between your browser, CLI, and LeetCode
- Minimal permissions: Only accesses leetcode.com pages
Legal Notice
This tool is for personal educational use only. LeetCode problem descriptions are the property of LeetCode. Do not use this tool to redistribute or publish problem content.
License
MIT
