TypeScript Formatter
Free client-side TypeScript formatter powered by Prettier. Beautify messy or minified TS with consistent indentation, quotes, and print width in your browser.
Strip single-line and block comments from source code in many languages — string-aware, private, and running entirely in your browser.
The Remove Comments tool is a free, 100% client-side utility that strips comments out of source code.
Paste your code, choose the language from the dropdown, and it removes single-line and block comments in one pass.
What sets it apart is that it is string-aware. A comment token that lives inside a string literal, a URL, or a docstring is left completely untouched.
Everything runs locally in your browser. Your code is never uploaded, stored, or seen by any server, so it is safe for private and proprietary work.
Removing comments deletes the human notes from your code while leaving the executable logic exactly as it was.
Comments are ignored by compilers and interpreters, so stripping them does not change how your program runs.
It simply produces a leaner, cleaner version of the same file.
There are plenty of everyday reasons to strip comments before you share or ship a file.
// TODO and // FIXME notes that should not travel to production.The workflow takes only a few seconds.
Most quick comment removers are naive regular expressions, and that is where they go wrong.
A regex that deletes everything after // will happily wreck a URL like "http://x.com", turning a valid string into a broken one.
This tool actually tracks whether it is inside a string, so those tokens are safe.
A hash inside a quoted value such as '#tag' stays put, because # is only a comment when it is real code, not text.
A Python triple-quoted docstring like """usage: run --flag # not a comment""" is a string, so nothing inside it is removed.
An SQL literal such as '-- literal' keeps its dashes, even though -- starts a comment elsewhere in the same query.
The same protection covers block markers, so a /* */ sequence written inside a string is preserved rather than misread as the start of a comment.
Choose any of these from the dropdown, and the matching comment syntax is applied automatically.
// line comments and /* */ block comments.// and /* */ rules as JavaScript.//, #, and /* */ comments.# comments, with triple-quoted docstrings preserved as strings.// and /* */ family./* */ block comments.// and /* */ comments.<!-- --> comments.-- line comments and /* */ block comments.# comments with word-aware handling.# comments.# comments and =begin/=end blocks, with strings preserved.Shell scripts have a subtle rule that trips up naive removers.
In Bash a # only starts a comment when it begins a word, so echo foo#bar prints foo#bar and the hash is not a comment at all.
This tool respects that, removing a # comment only when it truly starts one and leaving inline hashes like that intact.
Yes, if you want it to.
When you strip a full-line comment, an empty line is usually left where it used to be.
Tick the Remove blank lines left behind checkbox and those hollow lines are collapsed, giving you a tight, gap-free file.
Leave it unticked if you would rather keep the original line spacing.
Removing comments pairs naturally with formatting and minifying.
For PHP, tidy the stripped file with the PHP Beautifier before you commit it.
For front-end scripts, shrink the comment-free result further with the JavaScript Minifier for production.
Cleaning up a page? Run the markup through the HTML Minifier after stripping its comments.
And for stylesheets, feed the stripped CSS into the CSS Minifier to squeeze out the last few bytes.
You can remove comments from JavaScript, TypeScript, PHP, Python, the C family (C, C++, C#, Java, Go, Rust, and Swift), CSS, SCSS, Sass, LESS, HTML, XML, SQL, Shell, Bash, YAML, and Ruby. Pick the matching entry from the dropdown so the correct comment syntax is applied.
No. The tool is string-aware, so a comment token that appears inside a string literal or a URL is never removed. A value like "http://x.com" or '#tag' is left exactly as written, unlike naive regex removers that would corrupt it.
No. A Python triple-quoted docstring is a string, not a comment, so the tool leaves it fully intact. Only real # comments are stripped from your Python code.
Yes. Tick the "Remove blank lines left behind" checkbox and the empty lines left after full-line comments are stripped will be collapsed, giving you a compact, gap-free file. Leave it unticked to keep the original spacing.
No. Everything runs locally in your browser with client-side JavaScript. Your code is never uploaded, stored, or seen by any server, which makes the tool safe for private and proprietary source.
No. Comments are ignored by compilers and interpreters, so removing them does not affect how your program behaves. You get the same working code with the notes taken out.
💡 About this tool
//,#, or/* */that lives inside a string or a URL is left untouched.