Java comment remover

Remove comments from
Java code.

Strip Javadoc, line, and block comments from Java source files online. Preserves annotations, string literals, and code structure exactly.

Free, no signup Runs in your browser Instant, no upload Works on .java files

Before and after

Real-world Java code on the left. The same code with every comment removed on the right.

java-input.java
package com.example.orders;

import java.util.UUID;

/**
 * Repository for accessing the orders table.
 */
public class OrderRepository {

    // Database connection
    private final Connection conn;

    /** Constructor injection. */
    public OrderRepository(Connection conn) {
        this.conn = conn; // assigned once
    }

    /* Find an order by primary key. */
    public Order findById(UUID id) {
        // Build the query
        String sql = "SELECT * FROM orders WHERE id = ?"; // bind via prepared stmt
        return execute(sql, id);
    }
}
java-output.javacleaned
package com.example.orders;

import java.util.UUID;

public class OrderRepository {

    private final Connection conn;

    public OrderRepository(Connection conn) {
        this.conn = conn;
    }

    public Order findById(UUID id) {
        String sql = "SELECT * FROM orders WHERE id = ?";
        return execute(sql, id);
    }
}
Why use it

Built for Java specifically.

Java code tends to be heavily commented, Javadoc on every public method, generated TODOs, copyright headers. When sharing a snippet on Stack Overflow or building a clean reference example, you usually want all of that gone. Uncommenter handles every Java comment style and never touches your annotations or generics.

  • Removes //, /* */, and /** Javadoc */ blocks
  • Annotations like @Override and @Deprecated are preserved
  • String literals containing // are kept intact
  • Auto-detected from .java files
How it works

Strip comments in 30 seconds.

  1. 1

    Open the tool

    Head to uncommenter.com/tool. Nothing to install. Nothing to sign up for.

  2. 2

    Paste your Java code

    Drop your .java file in, or paste code into the editor. Auto-detection picks up Java from the extension or file content.

  3. 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. 4

    Copy or download

    Grab the cleaned output. Your code never left your browser.

FAQ

Java questions, answered.

Does it remove Javadoc?

+

Yes, Javadoc /** ... */ blocks are treated as block comments and removed by default. If you want to keep them, the API exposes a `preserveDocstrings` option that retains Javadoc-style blocks.

Are annotations safe?

+

Annotations like @Override or @Entity are not comments, they're language syntax, so they are always preserved.

What about Kotlin or Scala?

+

Kotlin and Scala have their own dedicated landing pages. Each handles language-specific features like nested block comments (Scala) and string templates (Kotlin).

Other languages

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 Java code now.

Free forever. No signup. No upload. Runs entirely in your browser.

Open uncommenter