JS/TS Beautify/Minify
100% LocalLightweight JavaScript/TypeScript formatter and minifier.
JS/TS beautify & minify
Lightweight formatter/minifier for simple JavaScript/TypeScript. For complex code, use a full parser.
Privacy note
This tool runs entirely in your browser. Your input is never uploaded, logged, or sent to AllDevToolsHub or anyone else, and it keeps working offline once the page has loaded.
How to Use JS/TS Beautify/Minify
Paste JavaScript
Enter minified or compressed JavaScript code.
Set Options
Choose indentation (2-space, 4-space, tab) and quote style.
Beautify
Click Beautify to reformat the code with clean indentation. Copy the result.
JS/TS Beautify/Minify: the essentials
The JS/TS Beautifier/Minifier formats JavaScript and TypeScript with consistent indentation and line breaks, or minifies it by stripping whitespace and comments. Runs locally, no code leaves your browser. For full Prettier-style formatting use a build tool; this is for quick one-off cleanups.
Key points
- Reflows js/ts beautify/minify into clean, readable output with standard indentation and keyword casing.
- Runs entirely in your browser, so production data never leaves your device.
- Supports multiple dialects and syntax variants for broad compatibility.
Learn More
What is JS/TS Beautify/Minify?
Frequently Asked Questions
Technical Deep Dive
JS/TS Beautify/Minify
Quickly beautify or minify simple JS/TS code in the browser. For complex syntax, prefer full parser-based tools.
Reliable Formatting
Idempotent, spec-compliant output, run it twice, get the same result.
Configurable Style
Indentation, quote style, and edge-case handling tunable to your team's conventions.
Big Inputs, Fast
Handles megabytes of code without freezing the tab, heavy lifting runs in workers.
JavaScript Beautify and Minify: Quick Cleanup vs. Full Pipeline
JavaScript files exist in two states for most projects: the source you edit (readable, commented, well-spaced) and the bundle you ship (compressed, mangled, single line). The two are produced by different tools at different times. This tool handles the middle ground, quick reformatting of snippets and basic minification, without the configuration overhead of a full bundler.
When to Use This Tool vs. a Real Build Pipeline
Use this tool for:
- Reading minified third-party code. Open the prod bundle, paste, get readable code back.
- Cleaning up debug output. Console-logged JS objects or stack-trace code that needs to be reviewed.
- One-off formatting of a snippet you're about to paste into a doc, a code review comment, or a blog post.
- Bundling tiny inline scripts. A 30-line script in an HTML page, minify before inlining for slight size savings.
Use a real build tool (Vite, Webpack, esbuild, Rollup, Parcel) when:
- You have a project with imports across files.
- You need source maps.
- You want variable mangling for max compression.
- You need tree shaking (remove unused exports).
- You're using TypeScript and need types stripped (this tool only formats).
The Beautify Operation
The beautifier reads your code and re-emits it with:
- Consistent indentation, 2 or 4 spaces (configurable). Tabs work but spaces are universal.
- Line breaks after statements, semicolons, closing braces.
- Spacing around operators,
a + bnota+b. - Bracket placement, Allman vs. K&R style.
- One statement per line,
a();b();becomes two lines.
The result is reviewable, diffable, debuggable JavaScript that respects the language's grammar.
The Minify Operation
The minifier reads your code and strips everything not needed for execution:
- All comments (
//line and/* */block) gone. - All whitespace collapsed, a single space remains where needed for token separation, zero where not.
- Newlines removed.
What this tool does NOT do (and a real minifier does):
- Variable mangling. Renaming
isUserLoggedIntoafor 90% savings. - Dead code elimination.
if (false) { ... }removed entirely. - Constant folding.
const x = 60 * 60 * 24precomputed to86400. - Property mangling.
obj.veryLongPropertyNametoobj.a(risky, only works with type info). - Tree shaking. Removing exports nobody imports.
For real bundle minification, Terser, SWC, and esbuild combine all of these and produce dramatically smaller outputs.
Source Maps: The Bridge Between the Two
A source map links a minified file back to its original source. Modern build tools emit .map files alongside bundles. In Chrome DevTools, when you debug a minified file, the source map lets you see and step through the original source.
This tool doesn't generate source maps, it's a one-shot transform with no link back. If you minify here, you lose the connection to original source. For production code where you need to debug from logs (error stack traces), use a real build pipeline that emits source maps.
Reading Minified Production Code
A common reason to beautify is to understand a competitor's website, a third-party library you didn't bring in directly, or a bundle that's failing in production with a useless stack trace.
Workflow:
- View page source or download the bundle.
- Paste minified code into beautifier.
- Read the structure: functions become readable, control flow becomes traceable.
- If variables are mangled (
a,b,c), rename them by hand based on usage context.
Browser DevTools have a built-in 'Pretty print' button (the {} icon in the Sources panel) that does the same thing. This tool is useful when you need to copy the result to a doc or share it with someone.
TypeScript Specifics
The tool handles TypeScript's extra syntax:
- Type annotations (
: string,: number), passed through. - Interfaces and type aliases, formatted with consistent indentation.
- Generics (
<T>), preserved. - Decorators (
@Component({...})), formatted but require careful parsing.
Important: this tool does NOT compile TypeScript to JavaScript. If you paste TS, you get TS back (reformatted). To strip types and get runnable JS, use tsc, esbuild --loader=ts, or swc.
Configuration Defaults
The tool picks sensible defaults that match common style guides:
- 2-space indent (Airbnb, Standard JS style).
- Single quotes for strings (configurable to double).
- Semicolons at end of statements.
- K&R brace style (opening brace on same line).
These match Prettier's defaults, so output is close to what a Prettier-formatted file would look like. For exact Prettier behavior, run Prettier directly, this tool is faster but slightly less precise.
Common Workflows
- Snippet cleanup. Paste a hand-written function with inconsistent spacing; get clean code to paste into your editor.
- Bundle inspection. Download
https://cdn.example.com/widget.min.js; beautify to see what it actually does. - Email/SMS-friendly minification. Some integrations want JS as a single line; minify and paste.
- Quick comparison. Beautify two pieces of code with the same formatter to compare them visually without manual reformatting.
- Inline script optimization. For a static HTML page with embedded
<script>, minify the script body before deploying.
Privacy
Both operations run as JavaScript in your browser. Source code, IP-sensitive logic, internal algorithms, none of it is sent over the network. Open DevTools Network during a transform: zero outbound requests.
03 When You Reach for It (Not What Prettier Is For)
Author-time formatting is Prettier's job and lives in your editor. A beautifier is for the moment you're handed JavaScript you didn't write and need to make sense of right now.
-
Minified vendor bundle debugging Source maps got lost in deploy. The error stack points at
app.min.js:1:48273. Beautify, then count braces, at least you'll get a line number worth setting a breakpoint on. -
Unpacking webpack output Tracking a bug to a specific module in a bundled output. Beautifying the IIFE wrapper and the
__webpack_require__table makes the module map readable enough to grep. -
Security investigation of eval'd code Suspicious code from a CSP report, a phishing payload, or an extension you're auditing. Beautify in a sandboxed tab, never paste into a tool that POSTs the input somewhere.
-
CDN-pulled bundles before they hit your build A third-party script your marketing team added. Beautify it once to see what it actually does before signing off on a
script-srcCSP rule that allows it. -
Pasting a snippet into a bug report The reporter sent the minified inline handler from "view source." A 10-second beautify turns it into a snippet someone can read in the ticket without leaving the page.
04 Worked Examples
if/else → BLOCK FORMif(a)b();else c()
if (a) {
b();
} else {
c();
}
Bare-statement if/else is valid JS but creates the classic dangling-else trap when more conditions get added later. Beautifying to explicit blocks is the standard ESLint curly rule, pleasant side-effect of running through a beautifier.
const Card=()=><div style={{padding:16,color:"red"}}>hi</div>;{ } is JSX expression, inner is an object:const Card = () => (
<div style={{
padding: 16,
color: "red"
}}>
hi
</div>
);A naive beautifier that doesn't distinguish JSX from JS will collapse the double-brace pattern into a single brace pair, silently breaking the component. Set the parser to babel or typescript, never plain esprima, when JSX is in scope.
const inc=n=>n+1;
const log=(...a)=>{console.log(...a);return a}function:const inc = n => n + 1;
const log = (...a) => {
console.log(...a);
return a;
};
Arrow functions and function expressions differ on this binding, arguments, and new-callability, they're not interchangeable. A beautifier must preserve the form it was given. If your tool rewrites n => n + 1 to function(n) { return n + 1 }, that's a bug, not a style choice.
05 Related Tools
A beautifier is one step in a forensic workflow. These tools handle the steps before and after.
Regex Tester
Once the bundle is readable, the inline regexes in it usually are not. Drop them in and step through the match to see what the bundler actually intended.
HTML to JSX
When the bundle reveals an inline template that should have been a component, convert the HTML to JSX before pasting back into your codebase.
JSON Formatter
Bundles embed JSON config, service-worker manifests, i18n tables, feature flags. Beautify the JS, extract the JSON literal, format it separately.