ktfmtter
A VS Code extension that runs ktfmt to format Kotlin code.
This project is based on the original vscode-ktfmt extension by Christopher Drost, with added support for selecting the formatting style.
Copyright © 2025-present Shape
Features
This is a fork of vscode-ktfmt, with added support for selecting a formatting style.
When activated, the extension prompts you to choose a ktfmt version, which will then be downloaded and cached.
- You can set ktfmtas the default formatter for Kotlin files by adding the following to yoursettings.jsonfile:
{
  // The version of ktfmt to use.
  // This is updated automatically when you select a version from the prompt.
  // Set this to `null` to be prompted to select a version again.
  "ktfmtter.ktfmtVersion": "0.47",
  // Optional: Set the formatting style. Can be 'kotlinlang' or 'google'.
  "ktfmtter.style": "kotlinlang",
  // Optional: Specify which Java runtime to use.
  // If not set, it will use the one marked as default in 'java.configuration.runtimes'.
  "ktfmtter.java-runtime": "JavaSE-17",
  "[kotlin]": {
    "editor.defaultFormatter": "shape-app.ktfmtter"
  }
}
- This extension uses your Java configuration to run ktfmt. It assumes you have the Java Language Support extension installed, which sets up an array of runtimes atjava.configuration.runtimes. If you haven’t configured this yet, you may need to add something like the following to yoursettings.json:
{
  "java.configuration.runtimes": [
    {
      "name": "JavaSE-17",
      "path": "/path/to/your/java/home",
      "default": true
    }
  ]
}
- If you don't want to use the defaultruntime to runktfmt, copy thenameproperty intoktfmtter.java-runtimeand this extension will use thatpathinstead.
Attribution
This project is based on the original work:
- vscode-ktfmt: Copyright (c) 2020-2023 Christopher Drost - GitHub
Third-party components:
- ktfmt: Copyright (c) Facebook, Inc. and its affiliates - GitHub
- VS Code Extension API: Copyright (c) Microsoft Corporation
Release Notes
1.1.1
- Added extension icon.
- Updated extension description.
1.1.0
- Added ktfmtter.selectVersioncommand to download and selectktfmtversion.
1.0.0
- Initial fork of crdrost/vscode-ktfmt.
- Added ktfmtter.stylesetting.