.KTS file extension

To open .KTS files on Windows, to view/edit: open the .kts file in a code editor (any plain-text editor works for reading).

To open a .kts file, use a text editor or IDE that supports Kotlin to view/edit it, and use the Kotlin command-line compiler (kotlinc -script) to run it. Some .kts files are specifically used as Gradle build scripts when named like build.gradle.kts.

Last updated: June 12, 2026

Open on your device

Choose your operating system for a dedicated step-by-step opening guide.

How to open .KTS files

Use these platform-specific instructions to open .KTS files safely.

Windows

  1. To view/edit: open the .kts file in a code editor (any plain-text editor works for reading).
  2. To run as a Kotlin script: install the Kotlin command-line compiler and run: kotlinc -script path\to\file.kts
Full Windows guide

Mac

  1. To view/edit: open the .kts file in a code editor (any plain-text editor works for reading).
  2. To run as a Kotlin script: install the Kotlin command-line compiler and run: kotlinc -script /path/to/file.kts
Full Mac guide

Linux

  1. To view/edit: open the .kts file in a code editor (any plain-text editor works for reading).
  2. To run as a Kotlin script: install the Kotlin command-line compiler and run: kotlinc -script /path/to/file.kts
Full Linux guide

iOS

  1. iOS does not commonly run Kotlin scripts directly; open the file as text for viewing, or transfer it to a desktop system to run with kotlinc -script.
Full iOS guide

Android

  1. Android does not commonly run Kotlin scripts directly; open the file as text for viewing, or transfer it to a desktop system to run with kotlinc -script.
Full Android guide

Security notes

  • .kts files are executable code when run (for example with kotlinc -script). Only run scripts from sources you trust, because they can perform actions allowed by your user account.
  • Review the contents in a text editor before executing—especially if the file came from the internet or a repository you do not control.
  • Gradle-related .kts files (such as build.gradle.kts) influence build behavior; treating an untrusted project as safe can result in running untrusted build logic during a build.

Before you run downloaded code

These files usually need a runtime (Python, Node, Java, …). They are not classic “file viruses,” but untrusted code can still do serious harm if you execute it. Prefer official packages, verify publishers, and scan archives or sketchy downloads when you are unsure.

We may earn a commission when you use affiliate links. This supports our free file extension guides.

Can't open this file?

These are the most common causes and fixes when .KTS files fail to open.

Common reasons

  • Double-clicking doesn’t run the script
  • Trying to run a Gradle Kotlin DSL file as a standalone script
  • Script fails because Kotlin tooling isn’t installed or on PATH

Fix steps

  1. Open the file in a code editor to inspect it as text.
  2. Run it from a terminal with the Kotlin compiler: kotlinc -script file.kts

What is a .KTS file?

A .kts file is a Kotlin source file in “script” form (Kotlin scripting). It contains Kotlin code meant to be executed directly by the Kotlin compiler in script mode rather than compiled as part of a typical Kotlin project.

Background

.kts is the standard extension for Kotlin scripts. Kotlin is a general-purpose programming language, and its scripting mode lets you run a Kotlin source file directly as a script.

In practice, many people encounter Kotlin scripts through build tooling: Gradle’s Kotlin DSL uses Kotlin-based build scripts, commonly named build.gradle.kts (and settings.gradle.kts). In that context, the .kts code configures a Gradle build rather than acting as a standalone script.

Because .kts is plain text code, it can be edited with most programming text editors. Running it depends on having Kotlin tooling (and, for Gradle build scripts, Gradle) set up correctly.

Known aliases: .kts

Further reading

Authoritative resources for more details on the .KTS format.

Common .KTS issues

Double-clicking doesn’t run the script

.kts files are source code; most operating systems do not execute them by default when you double-click.

  1. Open the file in a code editor to inspect it as text.
  2. Run it from a terminal with the Kotlin compiler: kotlinc -script file.kts

Trying to run a Gradle Kotlin DSL file as a standalone script

Files like build.gradle.kts are Gradle build scripts written in Kotlin DSL; they are meant to be evaluated by Gradle, not executed as a generic Kotlin script.

  1. If the file is named build.gradle.kts (or settings.gradle.kts), treat it as a Gradle build configuration.
  2. Run it through Gradle as part of the project (not via kotlinc -script).

Script fails because Kotlin tooling isn’t installed or on PATH

Running a .kts file requires the Kotlin command-line compiler (kotlinc). If it is missing or not available in your shell PATH, the command won’t work.

  1. Install the Kotlin command-line tools.
  2. Verify kotlinc is available by running: kotlinc -version
  3. Re-run the script using: kotlinc -script file.kts

FAQ

What is a .kts file used for?

It is a Kotlin script source file. It can be run as a script with the Kotlin compiler, and it is also used for Gradle’s Kotlin DSL in files like build.gradle.kts.

How do I run a .kts file?

Use the Kotlin command-line compiler in script mode: kotlinc -script file.kts (see Kotlin’s command-line compiler documentation).

Is .gradle.kts the same as .kts?

.gradle.kts is a specialized use of Kotlin scripts for Gradle’s Kotlin DSL. It is still Kotlin-based, but it is intended to be interpreted by Gradle as build configuration.

Does .kts have an official MIME type?

This should be checked against official registries. IANA’s media type registry is the authoritative place to verify standardized MIME types, and desktop mappings may also exist via freedesktop.org’s shared-mime-info.

Similar file extensions

Compare related formats in the same category to find the right tool faster.