JavaScript Formatter & Minifier
Format, beautify and minify JavaScript instantly in your browser. Clean up messy code or compress it with Terser to ship — free, private, and your code never leaves your device.
🔒 100% in-browser — your code never leaves your device.
What is JavaScript Formatting?
JavaScript formatting (also called beautifying or pretty-printing) rewrites code with consistent indentation, spacing and line breaks so it's easy to read and review. The code behaves identically before and after — only whitespace changes. Minifying does the reverse: it shortens names, drops comments and collapses whitespace to produce the smallest bundle that runs the same. This tool does both, entirely in your browser.
Key Features
Format and minify
Beautify messy JavaScript for readability or compress it with Terser for production — in one tool.
Byte-savings readout
See exactly how many bytes Terser saved, so you know the bundle impact.
100% private
All processing happens in your browser. Your code is never sent to a server.
Style controls
Choose 2-space, 4-space or tab indentation when beautifying.
Examples
Compact function
function add(a,b){return a+b}const doubled=[1,2,3].map(x=>x*2);console.log(doubled) Reindent a one-line script into readable statements.
Async/await
async function load(id){const r=await fetch(`/api/${id}`);if(!r.ok)throw new Error('bad');return r.json()} Format async functions and template literals cleanly.
Object literal
const cfg={retries:3,timeout:5000,headers:{'Content-Type':'application/json'},onError(e){console.warn(e)}} Lay out nested objects and shorthand methods line by line.
Class
class Counter{#n=0;inc(){this.#n++}get value(){return this.#n}} Indent class fields and methods for readability.
Common Use Cases
- Read minified code
- Beautify a minified or obfuscated script so you can understand and debug it.
- Code review
- Format JavaScript before a pull request for consistent, diffable code.
- Ship smaller bundles
- Minify production JavaScript with Terser to cut bytes and speed up load.
- Tidy a snippet
- Reformat a quick paste from the console or a gist into clean, readable code.
Technical Details
- Beautified with js-beautify
- Uses the proven js-beautify engine for predictable, configurable indentation and spacing.
- Minified with Terser
- Terser is the de-facto JavaScript minifier — it renames locals, drops dead code and strips comments while preserving behavior.
- Browser-based
- Runs entirely client-side; your code never leaves your device or hits a server.
Best Practices
- Format source, minify for production
- Keep readable code in your repo and let your build minify with Terser.
- Minify modern syntax with care
- Terser targets standard JavaScript; very new proposals may need a transpile step first.
- Don't hand-edit minified output
- Renamed variables make minified code hard to maintain — edit the source, then re-minify.
Frequently Asked Questions
How do I format JavaScript online?
How do I minify JavaScript?
What is the difference between formatting and minifying JavaScript?
Does minifying change what my code does?
Is my code safe with this tool?
Why did minify report an error?
What indentation should I use for JavaScript?
Related Tools
View all tools →CSS Formatter, Beautifier & Minifier
Code
Format, beautify and minify CSS instantly in your browser. Clean up messy stylesheets or compress them to ship — free, private, and your CSS never leaves your device.
HTML Formatter, Beautifier & Minifier
Code
Format, beautify and minify HTML instantly in your browser. Indent messy markup or compress it to ship — free, private, and your HTML never leaves your device.
SQL Formatter & Beautifier
Code
Format, beautify and minify SQL instantly in your browser. Supports PostgreSQL, MySQL, SQL Server, BigQuery, Snowflake, Oracle & SQLite. Free, private — your SQL never leaves your device.
Number Base Converter — Binary, Hex, Decimal & Octal
Conversion Tools
Convert between binary, hex, decimal, octal and any base (2-36) instantly. Free, private — all processing in your browser.
Base64 Decoder & Encoder
Encoding & Formatting
Decode and encode Base64 online for free. Real-time conversion with full UTF-8 and emoji support. 100% private — runs in your browser. No signup needed.
Base64 to Image Converter
Encoding & Formatting
Decode a Base64 string or data URI back into an image in your browser. Preview, read dimensions & MIME, then download as PNG, JPG, GIF, SVG. No upload.