Remove comments from
TypeScript code.
Strip comments from TypeScript files online, free, browser-based, and works on .ts, .tsx, .mts, and .cts.
.ts filesBefore and after
Real-world TypeScript code on the left. The same code with every comment removed on the right.
// API client for the orders service
import type { Order, OrderStatus } from "./types";
/**
* Fetch a single order by ID.
* Throws if the order doesn't exist.
*/
export async function getOrder(id: string): Promise<Order> {
// Validate UUID format
if (!isUuid(id)) throw new TypeError("Invalid id");
const res = await fetch(`/api/orders/${id}`); // GET request
if (!res.ok) throw new Error("Not found");
return res.json() as Promise<Order>; // assume server returns Order
}
const ALLOWED: OrderStatus[] = ["pending", "shipped"]; // status filterimport type { Order, OrderStatus } from "./types";
export async function getOrder(id: string): Promise<Order> {
if (!isUuid(id)) throw new TypeError("Invalid id");
const res = await fetch(`/api/orders/${id}`);
if (!res.ok) throw new Error("Not found");
return res.json() as Promise<Order>;
}
const ALLOWED: OrderStatus[] = ["pending", "shipped"];Built for TypeScript specifically.
TypeScript projects accumulate type-level comments, JSDoc blocks, and inline TODOs that are useful while writing but noisy when sharing snippets, generating compact bundles, or auditing diffs. Uncommenter keeps your type annotations and decorators intact while cleanly removing every flavor of comment, including TSDoc-style /** ... */ blocks if you want them gone.
- // line and /* */ block comments removed
- TSX support, including {/* */} inside JSX expressions
- Type annotations, decorators, and template literals preserved
- Auto-detection from .ts, .tsx, .mts, .cts extensions
- Optional preservation of TSDoc / JSDoc blocks
Strip comments in 30 seconds.
- 1
Open the tool
Head to uncommenter.com/tool. Nothing to install. Nothing to sign up for.
- 2
Paste your TypeScript code
Drop your .ts file in, or paste code into the editor. Auto-detection picks up TypeScript from the extension or file content.
- 3
Click 'Remove Comments'
The parser walks every character with a real state machine, strings, regex, and other context-sensitive parts are detected and left alone.
- 4
Copy or download
Grab the cleaned output. Your code never left your browser.
TypeScript questions, answered.
Does it understand TypeScript-only syntax?
+
Yes. Type aliases, interfaces, generics, decorators, and `as` casts are all preserved exactly as written, the parser only removes comment ranges, never type information.
Will it strip TSDoc blocks too?
+
By default the tool keeps docstring-style /** ... */ blocks. Disable the 'preserve docstrings' option to remove them.
Can I run it as part of a build?
+
Yes. Install the open-source `uncommenter` npm package and use the CLI: `uncommenter src/ -r -g "*.ts"`. See the API & CLI docs for flags.
Working in something else?
Plus 35+ more languages supported in the live tool , including HTML, YAML, Dockerfile, Terraform, Solidity, and more.
Try it on your TypeScript code now.
Free forever. No signup. No upload. Runs entirely in your browser.
Open uncommenter