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.

0 lines in0 lines outN/A runtime

Typical inputs process in under 5ms on modern browsers.

How to strip comments from code

Strip in 3 steps

Takes ~5 seconds
  1. 1
    Paste your code

    Add the text or source code containing comments into the input box.

  2. 2
    Strip comments

    Click "Strip Comments" to remove all matched comment patterns in one pass.

  3. 3
    Copy the result

    Copy or download the cleaned output with comments removed and structure intact.

This is a pattern-based heuristic, not a full language parser — sequences like // inside string literals may also be stripped. See the FAQ for details.

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.

Input
const x = 42; // answer to everything
const y = 7;
Output
const x = 42;
const y = 7;

Removes a multi-line /* block comment */ entirely, collapsing it to nothing.

Input
/* Configure settings
   for production */
const debug = false;
Output

const debug = false;

Strips an HTML comment and a # line comment in the same input.

Input
<!-- page header -->
<h1>Hello</h1>
color = red # default theme
Output

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

Four comment styles

Handles the most common comment formats found in code and markup.

  • // line comments
  • # line comments
  • /* block comments */
  • <!-- HTML comments -->
Structure preserved

Line numbers stay meaningful — comment-only lines become empty lines, not deleted lines.

  • Line numbers intact
  • Block comments collapsed
  • Trailing whitespace trimmed
Private by default

All processing runs in your browser. Your code is never uploaded anywhere.

  • No server upload
  • Works offline
  • Instant output
Privacy first: we never send your input to a server. Everything runs locally in your browser.

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?>
Yes. This tool uses pattern matching, not a language parser, so it cannot tell a // in a string literal apart from a real line comment. The // in a URL will trigger comment stripping for the rest of that line. This is a known limitation, documented clearly.
What happens if a /* block comment is never closed?>
Everything from the opening /* to the end of the input is treated as part of the comment and removed entirely. There is no error — the tool handles it gracefully.
Does stripping a comment delete its line entirely?>
No. A line that becomes empty after its comment is removed stays as an empty line. This keeps line numbers in surrounding code meaningful. Only trailing whitespace on that line is trimmed.
Can a // or # inside a /* block comment */ accidentally trigger line comment stripping?>
No. The tool processes input in a single left-to-right pass, so once a /* block comment */ is matched and consumed, any // or # inside it is already part of the removed content and is not re-processed.

Related String tools

Add Brackets Around String

Wrap each line of text in square brackets. Paste a list and get bracketed output instantly. Works fast in your browser.

Add Double Quotes Around String

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 Text

Add line numbers to each line of text with selectable separators. Choose no separator, a period, or a closing parenthesis.

Add Line Prefix to Text

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 Line Suffix to Text

Add a custom suffix to every line in your text. Enter a suffix once and apply it to all lines instantly. In your browser.

Add Parentheses Around String

Wrap each line of text in parentheses. Paste a list and get parenthesized output instantly. Works fast in your browser.

Add Single Quotes Around String

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.

Average Sentence Length Calculator

Calculate average sentence length instantly. Paste text and get the mean words per sentence in one click. In your browser.

Average Word Length Calculator

Calculate average word length instantly. Paste text and get the mean characters per word in one click. In your browser.

Byte Count Calculator

Calculate the total UTF-8 byte size of your text instantly. Paste content and get an exact byte count in one click.

Convert Four Spaces to Tab

Replace every group of four spaces with a tab character instantly. Paste any indented code or text and convert spacing in your browser.

Convert Tab to Four Spaces

Replace tab characters with four spaces. Clean up pasted text and align indentation instantly. Works fast in your browser.

Convert Tab to Single Space

Replace tab characters with a single space. Clean up pasted text instantly. Use it in your browser for quick, copy-ready results.

Count Lines in String

Count the number of lines in a text block. Paste your text and get the line count instantly. Works fast in your browser.

Empty Line Remover

Remove empty lines from text. Paste your text and get a cleaner block instantly. Use it in your browser for quick, copy-ready results.

Estimated Reading Time Calculator

Estimate how long text will take to read. Set words per minute and get instant reading time. Works fast in your browser.

Find Longest Line of Text

Find the longest line in a text block. Paste your text and get the longest line instantly. Works fast in your browser.

Find Shortest Line of Text

Find the shortest line in a text block. Paste your text and get the shortest line instantly. Works fast in your browser.

Firstname.Lastname to Last, First

Convert dot-separated names like john.doe into Last, First format with proper Title Case. Paste a list and get results instantly.

Numbers to Dollars

Prepend a dollar sign to each line of numbers. Format currency values instantly. Use it in your browser for quick, copy-ready results.

Paragraph Count Calculator

Count the total number of paragraphs in your text instantly. Paste content and get an exact paragraph count in one click.

Remove Dollar Signs from Numbers

Strip dollar signs from currency values. Paste your list and get clean numbers instantly. Use it in your browser for quick, copy-ready results.

Remove Repetitive Spaces

Collapse multiple spaces into a single space. Clean up pasted text instantly. Use it in your browser for quick, copy-ready results.

Sentence Count Calculator

Count the total number of sentences in your text instantly. Paste content and get an exact sentence count in one click.

String to camelCase Converter

Convert any string to camelCase instantly. Handles spaces, hyphens, underscores, PascalCase, and SCREAMING_SNAKE_CASE. Free and browser-based.

String to Lowercase

Convert text to lowercase instantly. Paste your text and get lowercase output in seconds. Use it in your browser for quick, copy-ready results.

String to Uppercase

Convert text to uppercase instantly. Paste your text and get uppercase output in seconds. Use it in your browser for quick, copy-ready results.

Text Case Inverter

Invert the case of every letter. Lowercase becomes uppercase and uppercase becomes lowercase. Works fast in your browser.

Text Length Calculator

Calculate the total character length of your text instantly. Paste any text and get an exact count in one click.

Text Reverser

Reverse text line by line. Paste your content and get reversed output instantly. Use it in your browser for quick, copy-ready results.

AI Token Count Calculator

Estimate AI token count instantly from your text input. Paste content and get a quick token estimate for prompt planning.

Truncate Lines by Character Count

Trim each line to a maximum character length. Set a line length count and truncate all lines instantly. In your browser.

Truncate Lines by Word Count

Trim each line to a maximum number of words. Set a word count and truncate all lines instantly. Works fast in your browser.

Unique Word Count Calculator

Count unique words in your text instantly. Paste content and get an exact unique word total in one click. In your browser.

Word Count Calculator

Count the total number of words in your text instantly. Paste any content and get an exact word count in one click.

Word to NATO Phonetic Alphabet Converter

Convert words or phrases into the NATO phonetic alphabet instantly. Get Alpha, Bravo, Charlie-style spellings for radio calls, spelling names, and forms.