JavaScript comment remover

Remove comments from
JavaScript code.

Remove comments from JavaScript code online. Free, instant, and runs entirely in your browser, no signup, no upload, nothing leaves your machine.

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

Before and after

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

javascript-input.js
// User authentication module
import { hash } from "bcrypt";

/* Configuration constants */
const SALT_ROUNDS = 10; // bcrypt cost factor
const SESSION_TTL = 60 * 60; // 1 hour

/**
 * Hash a plaintext password using bcrypt.
 * @param {string} password
 * @returns {Promise<string>}
 */
async function hashPassword(password) {
  // Validate input
  if (!password) throw new Error("required");
  return hash(password, SALT_ROUNDS); // returns a hash
}

const URL_PATTERN = /https?:\/\/[^\s]+/g; // not a comment
javascript-output.jscleaned
import { hash } from "bcrypt";

const SALT_ROUNDS = 10;
const SESSION_TTL = 60 * 60;

async function hashPassword(password) {
  if (!password) throw new Error("required");
  return hash(password, SALT_ROUNDS);
}

const URL_PATTERN = /https?:\/\/[^\s]+/g;
Why use it

Built for JavaScript specifically.

Stripping comments from JavaScript is useful before shipping production bundles, sharing code samples in interviews or tutorials, comparing two implementations side-by-side, or running automated minification. Most regex-based strippers break on the parts of JavaScript that look like comments but aren't, slashes inside regex literals like /https?:\/\//, // inside string literals like "https://example.com", and template literals containing comment-like text. Uncommenter walks the source character by character with a real parser, so all three keep working.

  • Single-line // and block /* */ comments
  • Regex literals are detected and preserved
  • Template literals (`hello ${name}`) keep their comment-like content
  • Auto-detection from .js, .jsx, .mjs, and .cjs extensions
  • JSDoc blocks can be preserved or removed via the docstring option
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 JavaScript code

    Drop your .js file in, or paste code into the editor. Auto-detection picks up JavaScript 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

JavaScript questions, answered.

Will it break my regex literals?

+

No. The parser detects regex literals using context (the character before the slash) and skips comment-detection inside them. /https?:\/\// stays intact.

Does it preserve JSDoc?

+

By default JSDoc /** ... */ blocks are removed along with regular block comments. Toggle the 'preserve docstrings' option in the tool, or pass `options.preserveDocstrings: false` to remove them when calling the API.

What about JSX and TSX files?

+

Both work. JSX uses the same JavaScript comment syntax, plus {/* ... */} comments inside JSX expressions, which Uncommenter handles correctly. TypeScript variants are covered by the dedicated TypeScript page.

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

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

Open uncommenter