JavaScript Formatter
Indent JavaScript so you can read it, or compact whitespace. js-beautify runs in this tab. It does not rename variables or transpile TypeScript.
JavaScript
Limits
- The input is limited to 2 MB of UTF-8 text (8 MB if you load a file). Larger files can run out of memory in a phone browser tab.
- Not a minifier that renames identifiers, and not a TypeScript/JSX compiler or linter.
- Syntax errors may cause messy output or a failure.
- Formatting can change ASI-sensitive line breaks in rare cases; check the result if you rely on automatic semicolon insertion.
Formatted JavaScript
How to use JS Formatter
- Paste JavaScriptType, paste or load a .js file.
- Choose indent or compact outputSet the indent size, or compact whitespace without renaming identifiers.
- Copy or downloadCopy the result or download a .js file.
Beautify, not a compiler
js-beautify reprints JavaScript with consistent indent and wrapping. Compact mode removes extra whitespace but does not mangle names (unlike Terser or esbuild minify). TypeScript, JSX and Flow syntax are not officially supported and may fail or wrap badly.
The tool does not run the code, resolve modules, or apply ESLint rules.
Frequently asked questions
Is my text or file uploaded?
No. Everything runs in your browser tab with JavaScript. Nothing you type, paste or drop is sent to a server, logged or stored by ALink Tools.
Can I format TypeScript or JSX?
Not reliably. This page is a JavaScript beautifier. Some TS/JSX may appear to work and then break. Use a TypeScript-aware formatter for those files.
Is compact mode the same as Terser?
No. Identifiers, quotes and dead code are left alone. Only extra whitespace is reduced.
Does the code run in this page?
No. It is only reprinted as text.
Related tools
All toolsCSS Formatter
Pretty-print or minify CSS in your browser with js-beautify.
HTML Formatter
Pretty-print or minify HTML in your browser with js-beautify.
JSON Formatter & Validator
Format, minify, sort keys, and catch syntax errors cleanly.
Regex Tester
Test a JavaScript regular expression, see matches and groups, and try a replacement.