JavaScript Formatter & Beautifier

Paste JavaScript code (including minified files) and get a clean, indented version.

Features

Beautify / minify toggle
Custom indentation
Syntax highlighting

How to Use

1. Paste JavaScript into the input box on the left.

2. Click Format to beautify, or Minify to compress.

3. Copy the formatted output.

About this tool

Minified scripts, code pasted from a chat or a bundle opened in the browser are hard to read on a single line. This formatter re-indents JavaScript based on braces, brackets and parentheses, puts statements on their own lines, and keeps strings and comments intact, so the structure of functions and objects becomes visible again. Choose two spaces, four spaces or tabs. Minify goes the other way, stripping comments and extra whitespace for a compact copy. It is a lightweight formatter that runs instantly in your browser rather than a full compiler, so it is ideal for reading and tidying code; for consistent formatting across a project, use Prettier or your editor's formatter.

Frequently Asked Questions

Can it reverse obfuscated or minified code to the original?
Formatting restores indentation and line breaks, which makes minified code readable, but shortened variable names such as a, b or e cannot be turned back into the original names. Source maps are needed for that.
Does it support TypeScript or JSX?
Basic TypeScript and JSX often format acceptably because the indentation follows braces and brackets, but type annotations and JSX tags are not parsed specially. Use Prettier for reliable formatting of those languages.
Is the minified output safe to use in production?
It removes comments and whitespace, but it does not rename variables or remove dead code like dedicated minifiers such as Terser or esbuild. For production builds, use your bundler's minifier, which also produces source maps.
Will formatting change how my code runs?
The formatter changes whitespace and line breaks only. Code that relies on automatic semicolon insertion across lines is the main risk; always run tests on formatted code before committing it.
Why does the output look odd around regular expressions?
A regex literal such as /[a-z]+/ can look like division to a lightweight formatter. If a line with a complex regex is split oddly, fix that line by hand or use a full parser-based formatter.

Related Tools