Code Comment Remover
Strip comments from JS, TS, CSS, Python or SQL while strings, regexes and formatting stay intact.
Code with comments
Cleaned code
no outputNo cleaned code yet
Paste code above or load an example.
Examples
URL in a string
const url = "https://example.com"; // noteconst url = "https://example.com";A regex-only stripper would corrupt the URL; the scanner treats it as a string.
License banner
/*! @license MIT */ const x = 1; /* note *//*! @license MIT */ const x = 1;License comments survive by default and are removed only when keep-license is off.
SQL quote escaping
SELECT 'it''s -- fine' FROM t; -- noteSELECT 'it''s -- fine' FROM t;The doubled quote keeps the string open until its real terminator.
About this tool
Code Comment Remover strips comments from JavaScript, TypeScript, CSS, Python and SQL without rewriting your code. A small state machine per language tracks strings, template literals, regex literals and quoting rules, so a URL inside a string or a hash inside a Python literal is never mistaken for a comment.
Options cover the practical details: keep license banners such as /*! and @license, collapse the blank lines left behind, trim trailing whitespace and remove Python docstrings. A unified-lite diff view shows exactly what changed, and a verifier compares brace, parenthesis and quote balance before and after to warn when an unusual construct may have confused the scanner.
This is extraction, not compression. Nothing is renamed, reformatted or minified, and no source leaves the browser tab. It is designed for trimming snippets for AI context windows, exercise skeletons and shareable code samples.
What this tool does not do
- Not a syntax validator; malformed input is handled best-effort.
- Template-literal ${} expressions are not parsed as full JavaScript sub-programs.
- SQL q'[…]' quote constructs are not supported.
- No minification, renaming or whitespace collapsing beyond the explicit options.
How to use this tool
Pick a language
Choose JS/TS, CSS, Python or SQL manually, or use auto-detect and override the badge if it guesses wrong.
Set removal options
Keep license banners by default; enable docstring removal, blank-line collapse or trailing-space trimming as needed.
Review the output
Check the counts and any verifier warning, then switch to diff view to see precisely which lines changed.
Copy or download
Copy the cleaned code or save it with the matching file extension.
Use cases
LLM context prep
Remove explanatory comments to fit more code into a prompt without changing behavior.
Exercise skeletons
Hand students code without the internal notes embedded in the original.
Sharing snippets
Post a clean sample in issues or chat without leaking TODO notes.
Comment syntax per language
| Language | Line comment |
|---|---|
| JS / TS | // |
| CSS | none |
| Python | # |
| SQL | -- |
A verifier flags changed brace, parenthesis or quote balance after stripping.
Common mistakes
Mistake:Using a regex such as //.* on JavaScript.
Fix:It deletes https:// inside strings and comment-like text in regex literals.
Mistake:Expecting minification.
Fix:Formatting and identifiers are preserved; use a minifier for size reduction.
Mistake:Removing a license banner by accident.
Fix:Keep-license is on by default; check the option before stripping.
Mistake:Ignoring a verifier warning.
Fix:It means a construct may be unsupported; inspect the diff before using the output.
Frequently asked questions
Why not just use a regex?
A regex like //.* cannot tell code from a URL inside a string, a regex literal such as /https?:\/\//, or a comment marker inside a CSS string. The tool uses a per-language scanner that tracks strings and quoting states, so code outside comments stays byte-for-byte intact.
Does it keep license headers?
Yes. Comments starting with /*!, or containing @license or @preserve, are preserved by default. Turn off the keep-license option if you really want them removed.
What happens to blank lines after removal?
By default the newline that ended a line comment stays, so line positions remain close to the original. Turn on collapse blank lines to squeeze runs of empty lines down to one.
Is my code uploaded?
No. Scanning, options, diff generation and download all happen in your browser tab. Nothing is sent to a server.
Does it minify code?
No. Identifiers, whitespace inside lines and formatting are untouched. The tool removes comments only; use a minifier if smaller output is your goal.
What if the scanner is unsure?
A verifier compares brace, parenthesis and quote balance before and after. If any invariant changes, it shows a warning and you can inspect the diff before copying the result.
References & standards
Related tools
.env Secret Safety Linter
Validate .env syntax and spot likely leaked credentials or placeholder secrets.
.gitattributes Generator
Build .gitattributes rules for line endings, Git LFS, GitHub linguist marks and merge drivers — with a one-line explanation for every rule.
.htaccess Generator
Build an Apache .htaccess — HTTPS redirects, rewrites, error pages, security headers, and basic auth
2D Fluid Dynamics & Particle Physics Sandbox
A physics playground with two engines sharing one canvas. The fluid mode runs a real Eulerian Navier-Stokes solver — semi-Lagrangian advection, explicit diffusion, Jacobi pressure projection and vorticity confinement — that you paint with dye and velocity using mouse or touch. The particle mode is a damped Verlet N-body engine with gravity wells, Coulomb attractors and repulsors, spring links, wall restitution and elastic circle collisions. Particle counts adapt to the device (100k target on WebGL2 desktop, 2k-5k on CPU fallback), and every configuration exports as runnable code: a Matter.js world, a PixiJS ticker setup, or a standalone vanilla Canvas engine.
A/B Test Sample Size Calculator
Compute required sample size per variant and test duration from baseline conversion rate, minimum detectable effect, alpha and power.
ABA Routing Number Validator
Validate 9-digit US ABA routing numbers with 3-7-1 Mod-10 breakdown.