🖊️

JS Beautifier

Format and pretty-print minified or compressed JavaScript with proper indentation and consistent spacing.

Input JavaScript
Formatted JavaScript

About JS Beautifier

JavaScript Beautifier reformats minified or single-line JavaScript into readable code with consistent indentation. It tokenises the code preserving string literals and comments, then re-indents based on opening and closing braces, brackets, and parentheses.

Features

  • Indent control - Choose 2 spaces, 4 spaces, or tab indentation.
  • String-literal safe - Content inside quotes is never modified.
  • Handles minified code - Adds line breaks after statements and blocks.

How to Use

  1. Paste your JavaScript (minified or compact) into the input area.
  2. Choose indentation style (2 spaces, 4 spaces, or tabs).
  3. Click Beautify - the formatted code appears in the output.
  4. Click Copy to copy the formatted JavaScript.

How It Works

The tool tokenizes the JavaScript and rebuilds it with consistent indentation inside blocks (functions, if/else, loops), newlines after statements, and proper spacing around operators. Comments and string literals are preserved exactly.

Example

Paste a minified library or bundle to make it readable for debugging: function a(b,c){return b*c;}var x=a(3,4); becomes a multi-line, properly indented version that is easy to read and edit.

FAQ

No. If the code was minified with variable renaming (e.g. Terser, UglifyJS), the short variable names cannot be restored. This tool only reformats the whitespace and structure.
No. All formatting runs in your browser. Your JavaScript is never transmitted anywhere.