+0
日增长
9,011
stars
1,430
forks
197
watchers
927
prs
1,613
issues
28
releases
README
&32;
&32;&32;&32;
&32;
This little beautifier will reformat and re-indent bookmarklets, ugly
JavaScript, unpack scripts packed by Dean Edward’s popular packer,
as well as partly deobfuscate scripts processed by the npm package
javascript-obfuscator.
Open beautifier.io to try it out. Options are available via the UI.
Contributors Needed
I'm putting this front and center above because existing owners have very limited time to work on this project currently.
This is a popular project and widely used but it desperately needs contributors who have time to commit to fixing both
customer facing bugs and underlying problems with the internal design and implementation.
If you are interested, please take a look at the CONTRIBUTING.md then fix an issue marked with the "Good first issue" label and submit a PR. Repeat as often as possible. Thanks!
Installation
You can install the beautifier for Node.js or Python.
Node.js JavaScript
You may install the NPM package js-beautify. When installed globally, it provides an executable js-beautify script. As with the Python script, the beautified result is sent to stdout unless otherwise configured.
bash
$ npm -g install js-beautify
$ js-beautify foo.js
You can also use js-beautify as a node library (install locally, the npm default):
bash
$ npm install js-beautify
Node.js JavaScript (vNext)
The above install the latest stable release. To install beta or RC versions:
bash
$ npm install js-beautify@next
Web Library
The beautifier can be added on your page as web library.
JS Beautifier is hosted on two CDN services: cdnjs and rawgit.
To pull the latest version from one of these services include one set of the script tags below in your document:
html
Example usage of a JS tag in html:
html
. . .
Older versions are available by changing the version number.
Disclaimer: These are free services, so there are no uptime or support guarantees.
Python
To install the Python version of the beautifier:
bash
$ pip install jsbeautifier
Unlike the JavaScript version, the Python version can only reformat JavaScript. It does not work against HTML or CSS files, but you can install _css-beautify_ for CSS:
bash
$ pip install cssbeautifier
Note: This project no longer supports Python 2.
Usage
You can beautify JavaScript using JS Beautifier in your web browser, or on the command-line using Node.js or Python.
Web Browser
Open beautifier.io. Options are available via the UI.
Web Library
After you embed the tags in your html file, they expose three functions: js_beautify, css_beautify, and html_beautify
Example usage of beautifying a json string:
js
const options = { indent_size: 2, space_in_empty_paren: true }
const dataObj = {completed: false,id: 1,title: "delectus aut autem",userId: 1,}
const dataJson = JSON.stringify(dataObj)
js_beautify(dataJson, options)
/ OUTPUT
{
"completed": false,
"id": 1,
"title": "delectus aut autem",
"userId": 1,
}
/
NTop issues
#1124CSS Single line formatting21 comments · 2017-02-02#1236SCSS maps issue20 comments · 2017-08-25#676Adjacent and direct descendant selectors are not space separated18 comments · 2015-04-26#396Option to preserve existing var and object alignment (like preserve_array_indentation)18 comments · 2014-01-31#1635 avoid insert empty line before <!DOCTYPE >17 comments · 2019-03-01#845 blade template formating bug16 comments · 2016-01-19#1446Create unit tests for Core 14 comments · 2018-07-09#1200Add support for Computed / Dynamic Object Property Names13 comments · 2017-05-30
Discussions
#2505v2.0.3 🌈0 comments · 2026-07-03#2354v1.15.3 🌈0 comments · 2025-02-10#2347v1.15.2 🌈0 comments · 2025-02-07#2339When will the next milestone be released (1.15.2) ?2 comments · 2025-01-12#2211What Stuff i have to know before i contribute ??1 comments · 2023-11-03#2210Welcome to js-beautify Discussions!1 comments · 2023-10-28
Latest release
v2.0.3 🌈 v2.0.3 2026-07-03What's Changed Pulling staging/main into main by @github-actions[bot] in https://github.com/beautifier/js-beautify/pull/2359 Pulling staging/release into release by @github-actions[bot] in https://github.com/beautifier/js-beautify/pull/2360 Fix minor crash for certain oddly formed .js files by @PierceLBrooks in https://github.com/beautifier/js-beautify/pull/2128 Bump webpack from 5.97.1 to 5.99.9 by @dependabot[bot] in https://github.com/beautifier/js-beautify/pull/2377 Bump glob from 10.4.5 to 10.5.0 by @jakub-pietrzak in https://github.com/beautifier/js-beautify/pull/2387 Bump pi