Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

ClearCode

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.

What it does

  • Accepts a single file or a .zip archive
  • 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 .zip is 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

How to use it

  1. Open clearcode.html in any modern browser.
  2. Drop a file or a .zip onto the upload area, or click to browse.
  3. Watch the process log as each file is scanned and cleaned.
  4. Download the result:
    • A single uploaded file downloads as a single cleaned file.
    • A .zip upload downloads as a .zip with 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.

Supported languages

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.

How comment detection works

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.

Privacy

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.

Limitations

  • 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.

License

Free to use, modify, and distribute.

About

Strip comments from any source file or zipped project, entirely in your browser.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages