Open LeetCode problems in your editor and test/submit solutions from the command line.
npm install -g leetcode-exporter
leetcode-exporter setupThen load the Chrome extension and register it (see Installation for details).
- 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
- Node.js 14 or higher
- Google Chrome browser
- One of: Cursor, VS Code Insiders, or VS Code
npm install -g leetcode-exporterleetcode-exporter setupThis will register the native host and open Chrome's extensions page.
- In Chrome, enable Developer mode (toggle in top-right)
- Click Load unpacked
- Paste the path from clipboard (or navigate to the extension folder)
- Click the extension icon in Chrome toolbar
- Click "Copy Command"
- Paste and run in terminal
- 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
# Test solution in current directory
leetcode-exporter test
# Test specific problem
leetcode-exporter test ./1-two-sum# 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 passed
# 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 trueFiles 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.rs
Example 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
}| Language | Extension |
|---|---|
| JavaScript | .js |
| TypeScript | .ts |
| Python | .py |
| Java | .java |
| C++ | .cpp |
| C | .c |
| Go | .go |
| Rust | .rs |
| Ruby | .rb |
| Swift | .swift |
| Kotlin | .kt |
leetcode-exporter uninstallThen remove the extension from Chrome.
- 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
- 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
- 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
Re-run the setup:
leetcode-exporter setup- 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
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.
MIT