Strip comments from source files without leaving your browser.
ClearCode is a single-file, client-side tool that removes comments from code — HTML, JavaScript, CSS, Python, Java, C-family languages, and more — while leaving strings, URLs, regex literals, and template literals untouched. Drop in one file or a full project archive and get back the same structure, cleaned.
- Accepts a single file or a
.ziparchive - Detects the language from the file extension, and falls back to a
secondary extension or a content scan when the extension is generic
(
.txt,.log, and similar) - Removes line comments and block comments using a string-aware parser, so nothing inside quotes, template literals, or regex patterns is touched
- Preserves the original folder structure when a
.zipis uploaded - Skips files it cannot confidently parse and returns them unchanged, rather than guessing and risking corruption
- Shows a live process log while files are being cleaned
- Runs entirely in the browser — no file is ever uploaded to a server
- Open
clearcode.htmlin any modern browser. - Drop a file or a
.ziponto the upload area, or click to browse. - Watch the process log as each file is scanned and cleaned.
- Download the result:
- A single uploaded file downloads as a single cleaned file.
- A
.zipupload downloads as a.zipwith the same structure, named<original-name>-clean.zip.
No installation, build step, or server is required. The file can be opened directly or hosted anywhere static files are served.
| Family | Extensions |
|---|---|
| Web | html, htm, vue, svelte, xml, svg, xsl |
| JavaScript / TypeScript | js, mjs, cjs, jsx, ts, tsx |
| Styles | css, scss, less |
| C-family | c, h, cpp, cc, hpp, cs, java, kt, kts, go, rs, swift, dart, scala, groovy, php |
| Data | json, json5, jsonc |
| Python / scripting | py, rb, sh, bash, zsh, pl, r |
| Config | yml, yaml, toml, ini, conf, env, properties, cfg, Dockerfile, .gitignore |
| Database | sql |
| Other | lua, rules |
Files with an unrecognized extension are left untouched rather than processed incorrectly.
The cleaner does not use regular expressions to strip comments, since a
naive regex approach can corrupt strings that happen to contain comment
characters (a URL with //, a shell string with #, and so on).
Instead it walks each file character by character, tracking whether the
current position is inside a string, a template literal, or a regex
literal, and only removes a comment when it is genuinely outside all of
those.
For HTML, <script> and <style> blocks are parsed with their own
JavaScript and CSS-aware logic rather than being treated as plain
markup.
After comments are removed, runs of more than one blank line are collapsed to keep the output tidy.
All processing happens locally in the browser using JavaScript. Files are never sent to a server, logged, or stored anywhere outside the current browser tab.
- Comment removal is based on syntax, not semantics — it will not detect or reformat anything beyond removing comments and trimming excess blank lines.
- Binary files are detected and skipped automatically.
- Very large archives are limited by available browser memory, since everything is processed in-memory rather than streamed to disk.
Free to use, modify, and distribute.