Vibeleaderboard
Index / tool
Visit github.com
Category
Developer Tools
Rank
Pricing
Open Source
Type
TOOL
Builder
block
GitHub
59 stars
Latest release
1.8.0
Date

About

CLI and IntelliJ plugin for formatting Kotlin code with consistent style enforcement via ktfmt.

What it does

Kotlin Formatter gives teams one formatting engine across editor saves, build tasks, staged commits, pushes, files, directories, and standard input. It applies ktfmt’s Google style with a 120-character width and can either rewrite code or report proposed changes.

Why it's ranked here

Its strongest case is workflow consistency. The editor and build integrations invoke the same command-line implementation, while Git-aware modes operate on staged or committed content instead of blindly checking working files. That makes enforcement practical across local editing and repository gates.

What's good

The pre-commit path preserves partially staged work by formatting Git blobs rather than the entire on-disk file. Dry runs, distinct exit codes, standard-input support, performance statistics, parallel formatting, and configurable binary discovery make the formatter useful in scripts and larger builds.

Tradeoffs

The daemon is explicitly experimental and accepts fewer formatting options than the main command. Java startup is slow enough to motivate that daemon. The IntelliJ integration starts disabled, configuration changes require a restart, and import optimization must remain off for Kotlin files.

How to use it well

It suits Kotlin teams that want identical formatting during editing, Gradle checks, commits, and pushes. Install the command centrally, enable editor formatting, format staged code before commit, then check committed code before push. It does not optimize imports or replace broader static analysis.

Technical notes+

kotlin-format/src/main/kotlin/xyz/block/kotlinformatter/Formatter.kt wraps ktfmt with GOOGLE_FORMAT.copy(maxWidth = 120). kotlin-format/src/main/kotlin/xyz/block/kotlinformatter/KotlinFormatter.kt selects standard-stream, working-directory, pre-commit, or pre-push configurations, formats entries through a parallel stream, sorts results, and reports changes or failures. kotlin-format/src/main/kotlin/xyz/block/kotlinformatter/FormattableBlob.kt reads Git objects and updates the index under synchronization, which supports partial staging. gradle-plugin/src/main/kotlin/xyz/block/kotlinformatter/FormattingTask.kt registers untracked apply and check tasks, invokes the external binary, and leaves lifecycle attachment to the consumer. kotlin-format/src/main/kotlin/xyz/block/kotlinformatter/Daemon.kt implements the experimental localhost socket server, dynamic port allocation, file locking, version checks, status and exit commands, and timeout cleanup.

Observed

License
Apache License 2.0
Primary language
Kotlin
Interfaces
Command-line tool, IntelliJ IDEA plugin, Gradle plugin, and Git hooks
CLI installation
Hermit package, pre-packaged distribution, or executable fat JAR
Distribution
Artifacts are available through Maven Central and GitHub Releases
Formatting engine
ktfmt using Google formatting style with a 120-character maximum width
Input surfaces
Files, directories, standard input, staged Git content, and committed Git content

Read from README.md, kotlin-format/src/main/kotlin/xyz/block/kotlinformatter/Cli.kt, kotlin-format/src/main/kotlin/xyz/block/kotlinformatter/Daemon.kt, kotlin-format/src/main/kotlin/xyz/block/kotlinformatter/ExitCode.kt, kotlin-format/src/main/kotlin/xyz/block/kotlinformatter/Formatter.kt, kotlin-format/src/main/kotlin/xyz/block/kotlinformatter/DaemonData.kt, kotlin-format/src/main/kotlin/xyz/block/kotlinformatter/Formattable.kt, gradle-plugin/src/main/kotlin/xyz/block/kotlinformatter/GradlePlugin.kt, kotlin-format/src/main/kotlin/xyz/block/kotlinformatter/SystemExiter.kt, gradle-plugin/src/main/kotlin/xyz/block/kotlinformatter/FormattingTask.kt, kotlin-format/src/main/kotlin/xyz/block/kotlinformatter/FormattableBlob.kt, kotlin-format/src/main/kotlin/xyz/block/kotlinformatter/FormattableFile.kt, kotlin-format/src/main/kotlin/xyz/block/kotlinformatter/FormattingStats.kt, kotlin-format/src/main/kotlin/xyz/block/kotlinformatter/KotlinFormatter.kt, kotlin-format/src/main/kotlin/xyz/block/kotlinformatter/GitProcessRunner.kt.

What it can do

  • Format Kotlin source code with consistent style

    Kotlin code filesFormatted Kotlin code with consistent styling

  • Enforce code style standards across Kotlin projects

    Kotlin codebase or project filesStyle-compliant Kotlin code

  • Format Kotlin code via command line interface

    Kotlin files through CLI commandsFormatted Kotlin code files

  • Format Kotlin code within IntelliJ IDE

    Kotlin code in IntelliJ editorFormatted Kotlin code in the IDE

  • Apply ktfmt formatting rules to Kotlin code

    Unformatted or inconsistently formatted Kotlin codeKotlin code formatted according to ktfmt standards

Tags

kotlinformatterintellijktfmt

Tech Stack

KotlinShell

Comments (0)

No comments yet

Editorially curated, with community endorsements as a secondary signal. Corrections welcome.