Skip to main content
The Deno 2 Release Candidate is here
Learn more

remove-comments

remove comments from JavaScript and TypeScript files

Installation

deno install -f --allow-read --allow-write -n clear https://deno.land/x/remove_comments@1.0.0/src/cli.ts

Usage

clear -i [inputFile] -o [outputFile]
import { removeComments } from "https://deno.land/x/remove_comments@1.0.0/mod.ts";
const commentedCode = `
/*
 * some block comment
 */
function greet(name: string) {
  console.log(`Hello ${name}`);
}
// single line comment
greet("John");
`;
console.log(removeComments(commentedCode));
deno run https://deno.land/x/remove_comments@1.0.0/example.ts

License

MIT