QCSunny Lab

JavaScript & TypeScript Code FormatterJavaScript / TypeScript 代码格式化与压缩

Statistics统计数据
Output转换输出

Format and minify JavaScript and TypeScript: paste code, get consistently indented output with a per-construct token count, plus optional identifier renaming and comment/whitespace stripping for the minified view.

The tokenizer is the same engine family the site's calculator uses — literals, template strings and regex-vs-division ambiguity are handled the way a real parser handles them, so formatting does not depend on running your code.

Frequently asked questions

Is it safe to paste production code?

The formatter is pure string processing in the browser with no network calls — but if policy still says no, run it offline: the page works without a server.

Formatter or linter — which do I need?

A formatter rewrites layout only; a linter flags semantics (unused vars, ==, etc.). This tool does the former; pair it with ESLint for the latter.

中文说明

JavaScript 与 TypeScript 的格式化与压缩:粘贴代码,得到缩进一致的输出与按语法结构分类的 token 统计,压缩视图还支持标识符重命名与注释/空白剥离。

分词器与本站计算器同源——字面量、模板字符串、正则与除法的歧义都按真正的解析器方式处理,格式化完全不执行你的代码。

常见问题

贴生产代码安全吗?

格式化是纯浏览器端字符串处理,无任何网络请求——若安全策略仍不允许,可离线使用:本页无需服务器即可工作。

要格式化器还是 linter?

格式化器只重排布局;linter 检查语义(未使用变量、== 等)。本工具做前者,与 ESLint 搭配使用。