Key features
JS, CSS, and HTML
Beautify all three languages from a single package. Dedicated
js-beautify, css-beautify, and html-beautify executables are included, or call each formatter programmatically.40+ configuration options
Control indentation size and character, brace style, line wrapping, operator position, comma placement, and more. Options are consistent across the CLI and library APIs.
EditorConfig support
Pass
--editorconfig to read indent style, indent size, and end-of-line settings directly from your project’s .editorconfig file.Templating language support
Preserve template syntax from Django, ERB, Handlebars, PHP, Smarty, and Angular inside HTML files. Use
--templating auto to detect automatically.In-source directives
Use
/* beautify ignore:start */ and /* beautify ignore:end */ comments to exclude sections from formatting, or preserve:start / preserve:end to keep existing formatting in JavaScript and HTML.Config file (.jsbeautifyrc)
Store your project settings in a
.jsbeautifyrc JSON file at any level of the directory tree. Settings support language-specific overrides for js, css, and html blocks.Available runtimes
| Runtime | Package | Languages |
|---|---|---|
| Node.js (library + CLI) | npm install js-beautify | JS, CSS, HTML |
| Python (library + CLI) | pip install jsbeautifier | JS only |
| Python CSS | pip install cssbeautifier | CSS only |
| Web / CDN | cdnjs script tags | JS, CSS, HTML |
Get started
Installation
Install JS Beautify for Node.js, Python, or as a web library via CDN.
Quickstart
Beautify your first file in under two minutes using the CLI or library API.