.kt File Extension

Learn what a .kt file contains, how to open and compile Kotlin source code, how Poly supports it, and how it differs from scripts and compiled files.

File extension details for .kt

Full Support
File typeKotlin source code
MIME type
EncodingUnicode plain text, commonly UTF-8
Operating systemsWindows, macOS, Linux
Opens withIntelliJ IDEA, Android Studio, Visual Studio Code, Any text editor
Poly supportYes. Poly recognizes .kt as readable Kotlin source code.
Indexed by PolyYes. Poly indexes readable source for exact and semantic search.
Preview in PolyYes. Kotlin source opens in Poly's code editor with syntax highlighting.
Poly agentYes. The Poly agent can read and reason about the source text.

What kind of file is a .kt?

A .kt file contains source code written in Kotlin. It is editable text, not a compiled application. A file can hold package and import directives, classes, interfaces, functions, properties, and other declarations. Kotlin's conventions recommend a matching name such as Customer.kt when a file contains one main class, or a descriptive upper-camel-case name when it contains several declarations.1

Kotlin source has no fixed magic bytes. Software normally recognizes it from the .kt suffix, project context, and syntax. IANA does not register a Kotlin-specific media type, so Poly classifies .kt as readable text/plain.2 UTF-8 is the safest encoding for moving source among current editors and build systems.

Kotlin scripts conventionally use .kts, while ordinary source uses .kt. Renaming one to the other does not necessarily make it valid for the other workflow, and renaming unrelated code does not translate it into Kotlin.

How do I open a .kt on my computer?

Any plain-text editor can open .kt files on Windows, macOS, or Linux. IntelliJ IDEA and Android Studio provide Kotlin support out of the box. Visual Studio Code has an official Kotlin extension, while other editors offer community integrations.3 Android Studio adds completion, lint checks, refactoring, and debugging for Kotlin in Android projects.4

To compile a small Kotlin/JVM program from a terminal, install the Kotlin compiler and run:

kotlinc hello.kt -include-runtime -d hello.jar
java -jar hello.jar

The first command compiles the source into a runnable JAR; it does not modify hello.kt.5 Most real projects use Gradle or Maven so dependencies, compiler versions, targets, and tests stay reproducible. Opening source as text does not execute it, but building an unfamiliar project can run plugins, scripts, tests, or application code. Review the project before running commands.

Poly support for .kt

Poly opens .kt files in a code-friendly viewer with Kotlin syntax highlighting, word wrap, and in-file search. It indexes readable source for exact and semantic search, so you can find a declaration by name or search for code by purpose. The Poly agent can summarize a file, explain a function, and help trace likely behavior.

Poly does not compile or execute the source, download dependencies, or reproduce an IDE's complete project model. Keep related source, tests, build files, and documentation together when module-wide context matters.

History of .kt

JetBrains began the Kotlin project in 2010 and unveiled it publicly in July 2011. Kotlin 1.0, its first official stable release, arrived in February 2016.36 The .kt suffix became the standard convention for ordinary Kotlin source, while .kts identifies scripts.

The extension does not say which backend a project targets. Kotlin can compile for the JVM, Android, JavaScript, WebAssembly, and native platforms.3 Build configuration determines the target and language settings.

File or extensionTypical role
.ktOrdinary human-readable Kotlin source
.ktsKotlin script or Kotlin-based build script
.javaJava source that can interoperate in JVM projects
.classCompiled JVM bytecode
.jarZIP-based archive of JVM classes and resources

Keep .kt files and build configuration in version control. Treat generated .class, JAR, JavaScript, WebAssembly, or native outputs as different artifacts. Decompilers may recover approximate source from some compiled targets, but comments, formatting, names, and original constructs can be lost. Changing a compiled filename to .kt never restores the source.

Footnotes

  1. Kotlin. Coding Conventions. Documents .kt source naming and multiplatform filename conventions.
  2. Internet Assigned Numbers Authority. Media Types Registry. The registry contains no Kotlin-specific media type.
  3. Kotlin. Frequently Asked Questions. Describes Kotlin's targets, history, and officially supported editors. 2 3
  4. Android Developers. Add Kotlin to an Existing App. Describes Kotlin tooling built into Android Studio.
  5. Kotlin. Kotlin Command-Line Compiler. Shows how .kt source is compiled into a JVM JAR and distinguishes .kts scripts.
  6. Kotlin. 10 Years of Kotlin: Past. Records the July 2011 unveiling and February 15, 2016 release of Kotlin 1.0.
© Poly Corp. 2026