Code Comment Remover
Remove comments from JS, CSS, HTML, and other code files.
Remove Comments from Code Online: Sanitize JS, CSS, Python, HTML, & SQL Scripts
You are preparing to hand over a client project, publish a repository to public GitHub, or submit a university programming assignment. During months of rapid development, your code has accumulated dozens of casual remarks: "// TODO: fix this terrible hack", "// test credentials: admin / pass123", or frustrated comments complaining about a third-party API.
Leaking sensitive internal notes, proprietary endpoint paths, or temporary developer shortcuts into production code is a massive embarrassment and a genuine security liability. Going through thousands of lines in fifty files to delete comments by hand is tedious and prone to human oversight.
Our free Code Comment Remover strips both single-line and multi-line comments across JavaScript, TypeScript, Python, CSS, HTML, SQL, and C-style languages in a single click. Most importantly, it safely recognizes string literals so URLs and quoted text containing slashes or hashes are never accidentally butchered.
Supported Language Comment Styles
C-Style, JS, TS, Java, PHP, C#
Removes both single-line and block comment structures:
// Single line comment/* Multi-line block comment */
Python, Shell, Ruby, YAML
Removes hash symbol comments and docstrings:
# Script annotation or debug note""" Multi-line docstring """
HTML & XML Markup
Strips browser-visible DOM comments:
<!-- Hidden developer note -->
SQL Databases (Postgres, MySQL)
Strips database queries and migration notes:
-- SQL migration comment/* Database query hint */
The String Literal Problem: Why Naive Regex Fails
Many inexperienced developers try stripping comments with a quick regular expression search like /\/\/.*$/gm. Look at what happens to this standard JavaScript code:
// Original code: const apiUrl = "https://api.example.com/v1/users"; // production endpoint // Broken by naive regex: const apiUrl = "https: // stripped everything after the double slashes!
Our tool parses lexical boundaries. It understands whether double slashes appear inside quotation marks ("..." or '...' or template literals \`...\`). Strings and regular expression literals remain pristine while actual code comments are stripped clean.
Why Sanitize Code Comments Before Shipping?
- Information Disclosure Prevention: Developers often leave internal server IP addresses, test account usernames, staging URLs, or deprecated database schemas in comments. Attackers routinely grep HTML source code and client bundles for juicy comments.
- Clean Client Deliverables: Deliver polished, enterprise-ready source code to paying clients without messy internal debates or unfinished TODO tickets visible in the codebase.
- Direct Payload Reduction: When serving scripts without a multi-stage Webpack/Rollup build pipeline, stripping comments reduces raw file sizes by 15% to 30% before transmission.
Frequently Asked Questions
Can I keep copyright or license header notices?
Many open-source licenses (like MIT or Apache 2.0) require retaining the original copyright notice at the top of the file. You can choose to preserve top-of-file license comments while stripping all internal inline remarks.
Does this tool modify code formatting or variable names?
No. It only removes comment characters and the associated comment text. All your indentation, variable names, logic flow, and line spacings are completely preserved.
Is my code safe when pasting it here?
Completely safe. The tool operates 100% client-side in your web browser. No source code or confidential comments are ever sent to an external server.