A zero-configuration VS Code extension that formats Kotlin code using ktlint. No setup required - just install and start formatting!
- 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
.ktand.ktsfiles - Status Notifications: Visual feedback on formatting success/failure
- Open VS Code
- Go to Extensions (
Ctrl+Shift+XorCmd+Shift+Xon Mac) - Search for "Ktlint Formatter"
- Click "Install"
Or install directly from the VS Code Marketplace
Command Line:
code --install-extension rnoro.vscode-ktlint-formatterOpen any Kotlin file (.kt or .kts) and format using:
- Keyboard:
Shift + Alt + F(Windows/Linux) orShift + 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"
}
}- VS Code: 1.85.0 or later
- Java Runtime: Required to execute ktlint (check with
java -version)
- 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
- Check Output Panel: View → Output → Select "Ktlint Formatter"
- Verify Java: Run
java -versionin terminal - Reload Extension: Press
F1→ "Reload Window"
- Check your internet connection
- Verify proxy settings if behind corporate firewall
- Check VS Code's network settings
Ktlint is stored at: ~/.vscode/globalStorage/rnoro.vscode-ktlint-formatter/ktlint
Found a bug or have a feature request? Please open an issue on GitHub.
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
MIT License - see LICENSE for details