JavaScript Formatter (pretty-printer) beautifies minified or compressed JavaScript code using Prettier under the hood. It restores readable indentation, line breaks, and spacing so you can understand, debug, or audit code that has been compressed for production delivery. This is particularly useful when working with third-party libraries, obfuscated scripts, or legacy code.
How it Works
1Paste your JavaScript code into the input editor.
2Prettier parses the code into an abstract syntax tree (AST) and reprints it with consistent style.
3The output uses 2-space indentation, single quotes, and standard ES formatting conventions.
4Copy the formatted code or download it as a .js file.
Frequently Asked Questions
Does formatting change what the JavaScript does?
No. Prettier is a semantics-preserving formatter — it only changes whitespace and line breaks, never the logic or meaning of the code. The formatted output executes identically to the original.
Can I format TypeScript, JSX, or TSX?
This formatter targets standard JavaScript (ES5+, ESNext). TypeScript-specific syntax (type annotations, interfaces, generics) and JSX may not format correctly. Use a dedicated TypeScript or JSX formatter for those file types.
What formatting rules does the tool use?
The tool uses Prettier's default configuration: 2-space indentation, double quotes, semicolons, 80-character print width. These are the most widely adopted JavaScript style conventions.
Can this tool unminify obfuscated JavaScript?
Formatting restores whitespace and line breaks but cannot reverse variable name mangling or other obfuscation techniques. The code will be more readable structurally, but shortened variable names like a, b, c remain as-is.