Tested tool guide
Tested browser tools
Checked August 16, 2026
What Kotlin Formatter does, with a checked example
Paste Kotlin code and the tool re-emits it with the spacing, indentation, and import order that the official Kotlin style guide requires, matching what ktlint produces with its default rules. It applies the conventions the compiler ignores: four-space indentation, spaces around operators and colons, comma spacing, brace placement, and lexicographic import sorting. The thing most users get wrong is that it is a formatter, not a linter or a compiler. It will not fix syntax errors, flag unused imports, or rewrite code into more idiomatic Kotlin. What goes in is what comes out, only re-spaced.
Worked example
A concrete input and expected output from the current implementation.
Input
import android.widget.TextView
import android.app.Activity
class MainActivity:Activity(){
fun greet(name:String){
val text=TextView(this)
text.text="Hello "+name
setContentView(text)
}
} ->
Expected output
import android.app.Activity
import android.widget.TextView
class MainActivity : Activity() {
fun greet(name: String) {
val text = TextView(this)
text.text = "Hello " + name
setContentView(text)
}
}
The formatter sorted the two imports alphabetically (android.app before android.widget), added the spaces the style guide requires around the supertype colon, the parameter-type colon, the equals signs, and the concatenation operator, and indented the nested bodies four spaces per level. Only whitespace and import order changed; the code does exactly what it did before.