Home/Developer Tools/JavaScript Formatter, Minifier & Obfuscator
📜

JavaScript Formatter, Minifier & Obfuscator

FREE

Format, minify or obfuscate JavaScript in the browser

Free · No sign-up required
Loading...

What the JavaScript tools do

Three transformations for JavaScript source: format lays out minified or messy code with consistent indentation and line breaks; minify removes comments and whitespace to shrink it; and obfuscate rewrites it into a form that is hard to read while behaving the same. All three run in your browser, so proprietary code is not uploaded.

Format

Before: const f=(a,b)=>{if(a>b){return a}else{return b}};for(let i=0;i<3;i++){console.log(f(i,2))} After: const f = (a, b) => { if (a > b) { return a; } else { return b; } }; for (let i = 0; i < 3; i++) { console.log(f(i, 2)); }

Formatting is purely cosmetic: it does not change semantics, rename anything or add or remove statements. Use it to read a library's minified build, a snippet pasted from a console, or code from a colleague who does not format.

Minify

What is removedWhat is not
CommentsVariable and function names
Indentation, line breaks, extra spacesStatement structure
Optional semicolons where safeString contents, regular expressions

This is whitespace-level minification, safe for any valid script. Production build tools (esbuild, Terser, SWC) go much further — renaming locals, inlining, dead-code elimination — and typically cut size by half or more versus a third here. Use those in a build; use this tool for a quick snippet, an inline handler or a bookmarklet.

Obfuscate — what it does and does not protect

Obfuscation renames identifiers to meaningless ones, encodes string literals, and restructures control flow so that reading the code takes effort. It raises the cost of casual copying and makes logic harder to follow in the browser's devtools. It does not make code secret: JavaScript runs on the client, so anything obfuscated can be deobfuscated with enough time, and secrets (API keys, credentials, licence checks) placed in client code remain recoverable. Treat obfuscation as a deterrent, keep secrets on the server, and be aware that obfuscated code is larger and slower than minified code.

  • Keep an unobfuscated copy in source control; obfuscated output is not editable.
  • Test the output — aggressive transformations occasionally break code that relies on Function.name, toString() or eval.
  • Do not obfuscate third-party libraries; it breaks their source maps and licences may require attribution.

Common uses

  • Reading a minified bundle to trace a bug when no source map is available.
  • Preparing a small script for an inline <script> tag, a Tampermonkey userscript or a bookmarklet.
  • Lightly protecting a widget or embed snippet delivered to third parties.
  • Normalising formatting before a diff.

Frequently asked questions

Does it support TypeScript or JSX?

Plain JavaScript (ES2015+). TypeScript type annotations and JSX will confuse the parser; compile them first.

Will minifying break my code?

Whitespace-level minification is safe for valid JavaScript. Code that depends on automatic semicolon insertion in unusual ways can break — add semicolons explicitly.

Can obfuscated code be reversed?

Yes, with effort. Deobfuscation tools recover structure, and string encoding is trivially undone at runtime. It deters, it does not secure.

Why is the obfuscated file bigger?

Encoded strings, decoder helpers and control-flow padding add bytes. Obfuscation trades size and speed for opacity.

Can I format with 4 spaces or tabs?

Not here; output uses 2 spaces. Prettier and editor formatters offer options.

Is my code uploaded?

No. All three operations run in your browser.

More tools in this category

📋
JSON Tools
View tree, format, validate and minify JSON
📄
YAML Beautifier & Validator
Format YAML and find the line that breaks it
📋
XML Tools
Beautify, validate and convert XML to JSON
🗃
SQL Formatter & Minifier
Lay out SQL clause by clause, or collapse it to one line
📝
Markdown Tools
Preview Markdown, convert to HTML and generate tables
🔑
JWT Encoder & Decoder
Decode a JWT's header and payload, or sign one with HS256