Strip Comments from Text & Code
Paste any code or text and instantly remove line comments, block comments, and HTML comments. Preserves line structure so your code stays readable after stripping.
Text or code with comments
Paste code or text containing // comments, # comments, /* block comments */, or <!-- HTML comments -->.
Pattern-based heuristic — not a full language parser. See notes below. Everything runs locally in your browser — nothing is uploaded.
Cleaned textComments removed. Line numbers and overall structure are preserved.
Typical inputs process in under 5ms on modern browsers.
How to strip comments from code
Strip in 3 steps
Takes ~5 seconds- 1Paste your code
Add the text or source code containing comments into the input box.
- 2Strip comments
Click "Strip Comments" to remove all matched comment patterns in one pass.
- 3Copy the result
Copy or download the cleaned output with comments removed and structure intact.
Who should use this tool?
- Developers cleaning up code snippets before sharing or minifying
- Technical writers removing inline comments from documentation examples
- Analysts stripping annotated config files down to bare values
Examples
Strips a // line comment, leaving the code line intact.
const x = 42; // answer to everything const y = 7;
const x = 42; const y = 7;
Removes a multi-line /* block comment */ entirely, collapsing it to nothing.
/* Configure settings for production */ const debug = false;
const debug = false;
Strips an HTML comment and a # line comment in the same input.
<!-- page header --> <h1>Hello</h1> color = red # default theme
<h1>Hello</h1> color = red
Remove comments from code or text fast
Strip the four most common comment styles from any pasted text or code in a single left-to-right pass. Useful for cleaning up snippets, config files, templates, and markup before sharing, minifying, or diffing.
This strip comments from code tool removes // line comments, # line comments, /* block comments */, and <!-- HTML comments --> using fast pattern-based matching. Unlike a full language parser, it works on any text format without setup. Block comments spanning multiple lines are collapsed entirely; comment-only lines become empty lines so the surrounding line numbers stay meaningful. Everything runs locally in your browser for instant, private processing.
Handles the most common comment formats found in code and markup.
- // line comments
- # line comments
- /* block comments */
- <!-- HTML comments -->
Line numbers stay meaningful — comment-only lines become empty lines, not deleted lines.
- Line numbers intact
- Block comments collapsed
- Trailing whitespace trimmed
All processing runs in your browser. Your code is never uploaded anywhere.
- No server upload
- Works offline
- Instant output
Tips for best results
Keep the tool's heuristic nature in mind when processing real source files.
- Avoid running this on code that embeds // or # inside string literals — those will be stripped too, as documented.
- For config files, double-check that # in values (like color hex codes without a space) aren't accidentally caught.
- Use a proper language-aware minifier or AST tool when precision matters for production code.
Frequently asked questions
Will // inside a URL like https://example.com be stripped?>
What happens if a /* block comment is never closed?>
Does stripping a comment delete its line entirely?>
Can a // or # inside a /* block comment */ accidentally trigger line comment stripping?>
Related String tools
Wrap each line of text in square brackets. Paste a list and get bracketed output instantly. Works fast in your browser.
Wrap each line of text in double quotes. Paste a list and get quoted output instantly. Use it in your browser for quick, copy-ready results.
Add line numbers to each line of text with selectable separators. Choose no separator, a period, or a closing parenthesis.
Add a custom prefix to every line in your text. Enter a prefix once and apply it to all lines instantly. In your browser.
Add a custom suffix to every line in your text. Enter a suffix once and apply it to all lines instantly. In your browser.
Wrap each line of text in parentheses. Paste a list and get parenthesized output instantly. Works fast in your browser.
Wrap each line of text in single quotes. Paste a list and get quoted output instantly. Use it in your browser for quick, copy-ready results.
Calculate average sentence length instantly. Paste text and get the mean words per sentence in one click. In your browser.
Calculate average word length instantly. Paste text and get the mean characters per word in one click. In your browser.
Calculate the total UTF-8 byte size of your text instantly. Paste content and get an exact byte count in one click.
Replace every group of four spaces with a tab character instantly. Paste any indented code or text and convert spacing in your browser.
Replace tab characters with four spaces. Clean up pasted text and align indentation instantly. Works fast in your browser.
Replace tab characters with a single space. Clean up pasted text instantly. Use it in your browser for quick, copy-ready results.
Count the number of lines in a text block. Paste your text and get the line count instantly. Works fast in your browser.
Remove empty lines from text. Paste your text and get a cleaner block instantly. Use it in your browser for quick, copy-ready results.
Estimate how long text will take to read. Set words per minute and get instant reading time. Works fast in your browser.
Find the longest line in a text block. Paste your text and get the longest line instantly. Works fast in your browser.
Find the shortest line in a text block. Paste your text and get the shortest line instantly. Works fast in your browser.
Convert dot-separated names like john.doe into Last, First format with proper Title Case. Paste a list and get results instantly.
Prepend a dollar sign to each line of numbers. Format currency values instantly. Use it in your browser for quick, copy-ready results.
Count the total number of paragraphs in your text instantly. Paste content and get an exact paragraph count in one click.
Strip dollar signs from currency values. Paste your list and get clean numbers instantly. Use it in your browser for quick, copy-ready results.
Collapse multiple spaces into a single space. Clean up pasted text instantly. Use it in your browser for quick, copy-ready results.
Count the total number of sentences in your text instantly. Paste content and get an exact sentence count in one click.
Convert any string to camelCase instantly. Handles spaces, hyphens, underscores, PascalCase, and SCREAMING_SNAKE_CASE. Free and browser-based.
Convert text to lowercase instantly. Paste your text and get lowercase output in seconds. Use it in your browser for quick, copy-ready results.
Convert text to uppercase instantly. Paste your text and get uppercase output in seconds. Use it in your browser for quick, copy-ready results.
Invert the case of every letter. Lowercase becomes uppercase and uppercase becomes lowercase. Works fast in your browser.
Calculate the total character length of your text instantly. Paste any text and get an exact count in one click.
Reverse text line by line. Paste your content and get reversed output instantly. Use it in your browser for quick, copy-ready results.
Estimate AI token count instantly from your text input. Paste content and get a quick token estimate for prompt planning.
Trim each line to a maximum character length. Set a line length count and truncate all lines instantly. In your browser.
Trim each line to a maximum number of words. Set a word count and truncate all lines instantly. Works fast in your browser.
Count unique words in your text instantly. Paste content and get an exact unique word total in one click. In your browser.
Count the total number of words in your text instantly. Paste any content and get an exact word count in one click.
Convert words or phrases into the NATO phonetic alphabet instantly. Get Alpha, Bravo, Charlie-style spellings for radio calls, spelling names, and forms.