A zero-configuration VS Code extension that formats Kotlin code using ktlint. No setup required - just install and start formatting!
Features
- Zero Configuration: No ktlint installation or setup needed
- Automatic Setup: Downloads ktlint (v1.8.0) automatically on first use
- Native Integration: Works with VS Code's built-in formatting commands
- Kotlin Standard: Follows the official Kotlin coding conventions
- Script Support: Formats both
.kt and .kts files
- Status Notifications: Visual feedback on formatting success/failure
Installation
From VS Code Marketplace
- Open VS Code
- Go to Extensions (
Ctrl+Shift+X or Cmd+Shift+X on Mac)
- Search for "Ktlint Formatter"
- Click "Install"
Or install directly from the VS Code Marketplace
Command Line:
code --install-extension rnoro.vscode-ktlint-formatter
Usage
Open any Kotlin file (.kt or .kts) and format using:
- Keyboard:
Shift + Alt + F (Windows/Linux) or Shift + Option + F (Mac)
- Context Menu: Right-click → "Format Document"
- Command Palette:
Ctrl+Shift+P → "Format Document"
Add to your VS Code settings.json:
{
"editor.formatOnSave": true,
"[kotlin]": {
"editor.defaultFormatter": "rnoro.vscode-ktlint-formatter"
},
"[kotlin-script]": {
"editor.defaultFormatter": "rnoro.vscode-ktlint-formatter"
}
}
Requirements
- VS Code: 1.85.0 or later
- Java Runtime: Required to execute ktlint (check with
java -version)
How It Works
- Extension activates when you open a Kotlin file
- On first use, ktlint binary (v1.8.0) is downloaded automatically
- Formatting requests are processed through ktlint
- Results are applied to your editor with status notifications
Troubleshooting
- Check Output Panel: View → Output → Select "Ktlint Formatter"
- Verify Java: Run
java -version in terminal
- Reload Extension: Press
F1 → "Reload Window"
Download fails
- Check your internet connection
- Verify proxy settings if behind corporate firewall
- Check VS Code's network settings
Manual ktlint download location
Ktlint is stored at: ~/.vscode/globalStorage/rnoro.vscode-ktlint-formatter/ktlint
Contributing
Found a bug or have a feature request? Please open an issue on GitHub.
Recommended Extensions
For the best Kotlin development experience in VS Code, use this extension together with:
- Kotlin Language Server - Official Kotlin language server from JetBrains
- Provides IntelliSense, code navigation, and refactoring
- Developed and maintained by JetBrains
License
MIT License - see LICENSE for details