Online Kotlin Compiler
Write, run and test Kotlin code online, right in your browser. This free online Kotlin compiler needs no installation or signup — just type your code and click Run.
Kotlin is a concise, modern JVM language and Google's preferred language for Android development, fully interoperable with Java.
How to use the Kotlin compiler
- Write or paste your Kotlin code in the editor.
- If your program reads input, open the I/O tab and type it into the STDIN box (one value per line).
- Click Run — the output and any errors appear in the output panel.
Sample: read input in Kotlin
fun main() {
val name = readLine() ?: ""
println("Hello, $name!")
}
Paste this into the editor, type your name in the STDIN box and click Run.
More Kotlin examples to try
Data classes and collections
A data class plus Kotlin's collection functions.
data class Student(val name: String, val marks: Int)
fun main() {
val students = listOf(Student("Asha", 91), Student("Ravi", 64), Student("Meena", 85))
val toppers = students.filter { it.marks >= 80 }.map { it.name }
println("Toppers: $toppers")
println("Average: ${students.map { it.marks }.average()}")
}
Null safety
Kotlin makes missing values explicit with ? types.
fun main() {
val input: String? = readLine()
val number = input?.toIntOrNull()
if (number != null) {
println("Double: ${number * 2}")
} else {
println("Please enter a whole number in STDIN")
}
}
Common Kotlin errors and how to fix them
Only safe (?.) or non-null asserted (!!.) calls are allowed- The value may be null. Use
?., provide a default with?:, or checkif (x != null). Val cannot be reassignedvalis read-only. Usevarfor values that change.Type mismatch: inferred type is String but Int was expected- Convert text with
toInt()ortoIntOrNull(). NumberFormatExceptiontoInt()received non-numeric text or an empty line. Check STDIN, or usetoIntOrNull().
Frequently asked questions
Is this online Kotlin compiler free?
Yes. It is completely free to use, with no signup required to write and run code.
Do I need to install anything?
No. It all works from your web browser, so there is nothing to download or set up — it works on Windows, macOS, Linux, Chromebooks and phones.
How do I give input to my Kotlin program?
Before clicking Run, type the input into the STDIN box under the I/O tab, one value per line. Your program reads it as standard input, just like typing in a terminal.
Is this good for learning Kotlin?
Yes. It is ideal for practising exercises, testing small programs and trying out ideas from tutorials, because you can run code instantly without configuring an environment.
Other online compilers
Python Compiler Java Compiler C Compiler C++ Compiler C# Compiler JavaScript Compiler TypeScript Compiler SQL Compiler React.js Compiler HTML Compiler Go Compiler Rust Compiler R Compiler PHP Compiler Swift Compiler Scala Compiler Dart Compiler Ruby Compiler Prolog Compiler Perl Compiler
Editor powered by OneCompiler.