Fork me on GitHub


ktfmt is a program that pretty-prints (formats) Kotlin code.

It always produces the same result, regardless of how the code looks initially, freeing developers to focus on essence.

It is by design non-customizable in order to promote consistency.


A ktfmt plugin that augments the Reformat Code action (⌥⌘L) is available from JetBrains Marketplace.


Spotless (details):

# build.gradle.kts
plugins { id("com.diffplug.spotless") }

// version and style are optional
spotless { kotlin { ktfmt('0.50').kotlinlangStyle() } }


ktfmt-gradle (details):

# build.gradle.kts
plugins { id("com.ncorti.ktfmt.gradle") }

ktfmt { kotlinLangStyle() }

Spotless (details):

# pom.xml

Download the jar from Maven Central and invoke it using java:

$ wget
$ java -jar ktfmt-0.50-jar-with-dependencies.jar [--kotlinlang-style] [files...]

Try It Online

Running v0.50