gitmyhub

js-beautify

JavaScript ★ 9.0k updated 12h ago

Beautifier for javascript

A tool that reformats minified or messy JavaScript, CSS, and HTML into clean, readable, properly indented code, available as a command-line tool, a Node.js or Python library, and a browser widget.

JavaScriptPythonNode.jsCSSHTMLsetup: easycomplexity 2/5

JS Beautifier is a tool that takes messy or compressed JavaScript, CSS, or HTML code and reformats it so it is easier to read. When code has been minified (stripped of all spacing to make it smaller) or obfuscated (deliberately scrambled to hide its logic), this tool reverses some of that and produces a cleanly indented, human-readable version. You can try it in your browser at beautifier.io without installing anything.

The project is available in three forms. There is a command-line tool that runs with Node.js or Python. There is a library you can add to a Node.js project or a Python project and call from your own code. There is also a web library version that you can include directly in an HTML page using a script tag, which exposes three functions for beautifying JavaScript, CSS, and HTML from within a browser.

The Node.js version handles JavaScript, CSS, and HTML. The Python version handles JavaScript only by default, though a separate Python package called cssbeautifier handles CSS. Configuration options let you control things like how many spaces to use for indentation and how to handle brackets and empty parentheses.

One notable use case is analyzing code that was packed using Dean Edwards' packer, an older JavaScript compression technique. The beautifier recognizes this format and can unpack it before reformatting. It also partially handles scripts processed by the javascript-obfuscator npm package, though the README does not claim complete deobfuscation for all cases.

The README notes that the project is widely used but currently short on contributors. The existing maintainers have limited time, and the project has open bugs as well as known issues with its internal design. Contributions are being actively encouraged, with a set of issues labeled as good starting points for new contributors.

Where it fits