Skip to content

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.

No Tracking Runs in Browser Free
Indent
Formatted JavaScript

🔒 100% in-browser — your code never leaves your device.

Reviewed for behavior-preserving beautification and Terser minification — Go Tools Engineering Team · Jun 5, 2026

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?
Paste your code into the input box and click Format. The tool reindents it with consistent spacing and line breaks, then lets you copy it. Everything runs locally in your browser — nothing is uploaded.
How do I minify JavaScript?
Paste your code and click Minify. The tool runs Terser to rename locals, remove comments and collapse whitespace into the smallest equivalent script, and shows how many bytes you saved.
What is the difference between formatting and minifying JavaScript?
Formatting (beautifying) adds indentation and spacing to make code readable. Minifying shortens names and strips whitespace and comments to shrink the bundle for faster loading. Both run with the same behavior as the original.
Does minifying change what my code does?
No. Terser preserves behavior — it only renames local variables and removes whitespace, comments and unreachable code. The minified script runs the same as the source.
Is my code safe with this tool?
Yes. All formatting and minifying happen locally in your browser using JavaScript — your code is never sent to any server, logged, or stored. That makes it safe for proprietary or unreleased code, unlike server-side tools that receive a copy of everything you paste.
Why did minify report an error?
Terser needs syntactically valid JavaScript. If you paste an incomplete snippet or TypeScript/JSX, parsing fails — format works on a best-effort basis, but minification requires valid JS. Fix the syntax or transpile first, then try again.
What indentation should I use for JavaScript?
Two spaces is the most common default in modern JavaScript and keeps diffs compact; four spaces and tabs are also widely used. Pick one and apply it consistently — this tool supports all three when beautifying.

Related Tools

View all tools →