How do you convert Kotlin code to Java?

← Kotlin answers

There is no official Kotlin-to-Java converter. In Android Studio or IntelliJ use Tools > Kotlin > Show Kotlin Bytecode, then Decompile, to see equivalent Java for a file.

  • Open the Kotlin file, choose Tools > Kotlin > Show Kotlin Bytecode, then click Decompile at the top of the panel.
  • The decompiled Java is generated from bytecode, so it is verbose and contains helper code (Intrinsics checks, synthetic accessors). Treat it as a reference, not clean source.
  • For hand conversion, map each feature: properties become fields with getters and setters, data classes need equals, hashCode, toString and copy logic, null safety becomes annotations, and extension functions become static methods.
data class User(val name: String, val age: Int = 18)
 
// Roughly the Java you would write by hand:
// public final class User {
//     private final String name;
//     private final int age;
//     public User(String name, int age) { this.name = name; this.age = age; }
//     public String getName() { return name; }
//     public int getAge() { return age; }
//     // plus equals, hashCode, toString and copy
// }

If the aim is to call Kotlin from existing Java code, you do not need to convert anything: the two languages interoperate, and annotations such as @JvmStatic and @JvmOverloads shape how Kotlin appears to Java callers.

Related questions

Start debugging smarter today

Try Bugsee for free — no commitments, no hidden fees.

Free sign upLive demoNo credit card required