Skip to content

feat: add remove comments option #2331 - #2526

Open
kalpit118 wants to merge 1 commit into
beautifier:mainfrom
kalpit118:feat/remove-comments
Open

feat: add remove comments option #2331#2526
kalpit118 wants to merge 1 commit into
beautifier:mainfrom
kalpit118:feat/remove-comments

Conversation

@kalpit118

@kalpit118 kalpit118 commented Aug 19, 2026

Copy link
Copy Markdown

Description

  • Source branch in your fork has meaningful name (not main)

Fixes Issue: #2331

Details of Feature Added

Added a "Remove Comments" feature to the js-beautify web application. A new checkbox option in the user interface allows users to strip comments from their HTML, JavaScript, and CSS code before the beautification process is applied.

Screenshot

image

To ensure the structural integrity of the code, the comment removal is implemented using a robust, character-by-character parsing function rather than simple regular expressions. This ensures that string literals, regular expressions, and URLs containing comment-like syntax are not accidentally corrupted, while properly handling edge cases like multiline comments, inline comments, and different line endings (LF/CRLF).

Input

Raw code (HTML, JS, or CSS) containing comments.
Example:

// Initialize the variable
let url = "https://example.com"; /* string literal */

Output

Code with all comments safely removed, preserving string literals and layout:

let url = "https://example.com"; 

Before Merge Checklist

These items can be completed after PR is created.

(Check any items that are not applicable (NA) for this PR)

  • JavaScript implementation
  • Python implementation (NA if HTML beautifier) - NA (Web-only UI feature)
  • Added Tests to data file(s)
  • Added command-line option(s) (NA if web-only feature) - NA (Web-only UI feature)
  • README.md documents new feature/option(s)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant