JavaScript Beautifier

Format messy or minified JavaScript into readable source text.

Use 0 for no indentation; invalid values reset to 4 spaces before formatting.

Use 0 to keep lines unwrapped; invalid values reset to 0 before formatting.



Question

What is Beautifying JavaScript?

Beautifying JavaScript means rewriting source text with consistent whitespace, indentation, line breaks, and optional wrapping so the code is easier to scan and review. It is useful for quick cleanup of compact snippets, generated examples, copied browser-console code, small functions, and inherited scripts where the structure is hard to read because everything is packed onto one line.

This tool formats the text you enter in the browser and writes the result to the output box. It is designed for common JavaScript syntax, including functions, classes, objects, arrays, comments, strings, regular expressions, template literals, imports, exports, and control-flow blocks. Options let you choose indentation size, use tabs instead of spaces, wrap long lines, preserve existing line breaks, place operators around wrapped lines, keep array indentation, control function spacing, and end the output with a trailing newline.

The beautifier is a formatter, not a linter, minifier, transpiler, bundler, security scanner, or runtime validator. It does not execute code, rename variables, check browser or Node.js compatibility, resolve modules, or guarantee that invalid JavaScript becomes valid. Because JavaScript whitespace, comments, strings, regular expressions, template literals, automatic semicolon insertion, and modern syntax can be context-sensitive, review the output before using it in production.

For safety, treat pasted JavaScript like source code from any other source. Do not run third-party code just because it formats successfully, and be especially careful with snippets that contain network calls, dynamic evaluation, DOM writes, credential handling, package-install commands, or obfuscated logic.