JavaScript / TypeScript Formatter & Minifier

Beautify or minify JS and TS code instantly β€” powered by Prettier and Terser, entirely in your browser

About this tool

The ToolNinja JavaScript/TypeScript Formatter beautifies or minifies JS and TS code directly in your browser, using the same Prettier engine behind most editor "format on save" integrations, plus Terser for minification. Use Format when you've got code pasted from a Slack message, a Stack Overflow answer, or a minified bundle, and want it readable again β€” proper indentation, consistent quote style, and semicolon handling, all configurable. Use Minify when you need the opposite: compact, production-sized output with variable names shortened and whitespace stripped. TypeScript gets its own parser so type annotations, generics, and interfaces format correctly instead of erroring out on a plain JavaScript parser. Minify intentionally targets plain JavaScript only β€” Terser doesn't understand TypeScript syntax, so format TypeScript down to JS first if you need a minified build. Everything runs locally in your browser via WebAssembly-free pure JS β€” your source code is never uploaded anywhere.

When to use it

  • β†’Cleaning up minified or poorly formatted JS/TS pasted from elsewhere
  • β†’Quickly minifying a small script before inlining it in an HTML page
  • β†’Standardizing quote style and semicolon usage across a snippet
  • β†’Formatting a TypeScript interface or type definition for readability

Tips

  • β—†Minify expects plain JavaScript β€” if you're working in TypeScript, format it first, then strip types in your build tool before minifying.
  • β—†Toggling single vs. double quotes only affects string literals Prettier can safely normalize β€” it won't touch quotes inside template literals.
  • β—†The minified output reduction percentage reflects raw byte size, not gzip β€” real-world transfer savings are usually larger once compression is applied.

Frequently asked questions

Does this use the real Prettier?

Yes β€” it loads Prettier's standalone browser build with the Babel/TypeScript and ESTree plugins, the same formatting engine used by Prettier's own online playground and most editor integrations.

Why did minify fail on my code?

Terser only parses valid JavaScript. If your input has TypeScript-only syntax (type annotations, interfaces, enums), format it to JS first, or paste the compiled output instead.

Is my code sent to a server?

No. Formatting and minification both run entirely client-side in your browser. Nothing you paste here is uploaded or logged.

Related tools

πŸ₯· ToolNinja