Remove comments from
Kotlin code.
Remove comments from Kotlin source files online. Strips KDoc, line, and block comments without touching string templates or annotations.
.kt filesBefore and after
Real-world Kotlin code on the left. The same code with every comment removed on the right.
package com.example.orders
import java.util.UUID
/**
* Repository for the orders table.
*/
class OrderRepository(private val db: Database) {
// Find by id
fun findById(id: UUID): Order? {
// Validate
require(id.toString().isNotBlank()) // not blank
val sql = "SELECT * FROM orders WHERE id = '${id}'" // template
return db.query(sql)
}
/* Count rows */
fun count(): Int = db.scalar("SELECT COUNT(*) FROM orders") // single result
}package com.example.orders
import java.util.UUID
class OrderRepository(private val db: Database) {
fun findById(id: UUID): Order? {
require(id.toString().isNotBlank())
val sql = "SELECT * FROM orders WHERE id = '${id}'"
return db.query(sql)
}
fun count(): Int = db.scalar("SELECT COUNT(*) FROM orders")
}Built for Kotlin specifically.
Kotlin files in Android and server-side projects accumulate KDoc on every public member, inline `//` notes, and TODO markers. When sharing a clean snippet on Stack Overflow or generating a compact training example, removing all of that up front is the fastest path. Uncommenter strips every Kotlin comment style while leaving annotations, type parameters, and string templates intact.
- // line and /* */ block comments removed
- KDoc /** ... */ blocks removed (or preserved via option)
- Annotations like @JvmStatic preserved
- String templates ${name} kept intact
- Auto-detected from .kt and .kts files
Strip comments in 30 seconds.
- 1
Open the tool
Head to uncommenter.com/tool. Nothing to install. Nothing to sign up for.
- 2
Paste your Kotlin code
Drop your .kt file in, or paste code into the editor. Auto-detection picks up Kotlin from the extension or file content.
- 3
Click 'Remove Comments'
The parser walks every character with a real state machine, strings, regex, and other context-sensitive parts are detected and left alone.
- 4
Copy or download
Grab the cleaned output. Your code never left your browser.
Kotlin questions, answered.
Does it remove KDoc?
+
Yes by default. KDoc /** ... */ blocks are treated as regular block comments. Use the `preserveDocstrings` option to keep them.
Are string templates handled?
+
Yes. Kotlin string templates such as $name and ${expression} are tracked as part of string state, so // or /* inside them is preserved.
What about Kotlin scripts (.kts)?
+
Both .kt and .kts files are auto-detected and processed identically.
Working in something else?
Plus 35+ more languages supported in the live tool , including HTML, YAML, Dockerfile, Terraform, Solidity, and more.
Try it on your Kotlin code now.
Free forever. No signup. No upload. Runs entirely in your browser.
Open uncommenter