A web-based tool that automatically analyzes and refactors Python code using AST parsing and intelligent algorithms. Perfect for improving code quality and learning best practices.
Try it now: https://code-refactor-tool-production.up.railway.app
Or: https://code-refactor-tool.onrender.com
- 🔍 AST-Based Analysis - Deep code analysis using Python's Abstract Syntax Trees
- 🔤 Smart Variable Renaming - Automatically renames unclear single-letter variables
- 🔄 Conditional Simplification - Extracts complex conditionals into readable variables
- 📝 Duplicate Code Detection - Identifies and highlights repeated code patterns
- 🎨 Beautiful Web Interface - Modern, responsive UI with syntax highlighting
- ⚡ Real-time Processing - Instant refactoring results
- 📊 Code Quality Suggestions - Actionable improvement recommendations
- Backend: Python, FastAPI, AST parsing
- Frontend: HTML5, CSS3, JavaScript, Prism.js
- Deployment: Railway, Uvicorn
- Analysis: AST, astor, custom refactoring algorithms
-
Clone the repository
git clone https://github.com/yourusername/code-refactor-tool.git cd code-refactor-tool -
Install dependencies
pip install -r requirements.txt
-
Run the application
python run.py
-
Open your browser Navigate to http://localhost:8000
# Build and run with Docker
docker build -t code-refactor-tool .
docker run -p 8000:8000 code-refactor-toolPaste your Python code in the left editor Select refactoring options: ✅ Rename Unclear Variables ✅ Extract Duplicate Code ✅ Simplify Complex Conditionals ✅ Extract Methods ✅ Remove Dead Code
Click "Refactor Code" or press Ctrl+Enter View results in the refactored code panel Check suggestions for further improvements
Ctrl+Enter - Refactor code Ctrl+/ - Focus code editor Esc - Clear code editor
The tool includes several sample codes to test: Complex Function - Long functions with multiple responsibilities Nested Conditionals - Deeply nested if-else statements Duplicate Code - Repeated logic across functions Messy Variables - Poorly named single-letter variables