What is a .kt file?
Kotlin Source File · Code and data · JetBrains · 2011
A .kt file is Kotlin source code, a concise, modern language that runs on the Java Virtual Machine and is now Google's preferred language for Android app development.
What is a .kt file used for?
Kotlin interoperates fully with Java but with less boilerplate and safer handling of null values. It compiles to JVM bytecode, and Android Studio uses it as the default language for new Android apps.
Beyond Android, Kotlin is used for server back ends and can even compile to native or JavaScript. The files are plain text; IntelliJ IDEA and Android Studio are the usual editors.
How to open a .kt file
The .kt format opens in the following apps, grouped by operating system. If one app does not work, try another from the same list. For a step-by-step walkthrough, see how to open a .kt file.
Windows
- IntelliJ IDEA
- Android Studio
- VS Code
macOS
- IntelliJ IDEA
- Android Studio
- VS Code
Linux
- IntelliJ IDEA
- Android Studio
- VS Code
How to convert a .kt file
You can convert a .kt file to class (bytecode), jar using a conversion tool or the export menu of an app that opens it.
.kt file signature (magic bytes)
Programs recognise a .kt file by the bytes at the start of the file, not by its name. These are the signatures for Kotlin.
| Hex signature | Offset | Note |
|---|---|---|
| (no fixed signature) | 0 | plain text; no fixed magic bytes |
See the full magic-numbers reference for every format.
Frequently asked questions
What is a .kt file?
A .kt file is Kotlin source code, a concise, modern language that runs on the Java Virtual Machine and is now Google's preferred language for Android app development.
How do I run a .kt file?
Compile with kotlinc file.kt then run on the JVM, or build it inside IntelliJ IDEA or Android Studio.
Is Kotlin better than Java for Android?
Google recommends Kotlin for new Android apps because it is more concise and safer around null values, while still working with existing Java code.
How do I open a .kt file?
Any text editor shows the source. IntelliJ IDEA or Android Studio add full Kotlin tooling.
Related formats
Sources
Details on this page were checked against authoritative references: