# JS Beautifier
![CI](https://github.com/beautify-web/js-beautify/workflows/CI/badge.svg)
[![PyPI version](https://img.shields.io/pypi/v/jsbeautifier.svg)](https://pypi.python.org/pypi/jsbeautifier)
[![CDNJS version](https://img.shields.io/cdnjs/v/js-beautify.svg)](https://cdnjs.com/libraries/js-beautify)
[![NPM @latest](https://img.shields.io/npm/v/js-beautify.svg)](https://www.npmjs.com/package/js-beautify)
[![NPM @next](https://img.shields.io/npm/v/js-beautify/next.svg)](https://www.npmjs.com/package/js-beautify?activeTab=versions)
[![Join the chat at https://gitter.im/beautify-web/js-beautify](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/beautify-web/js-beautify?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Twitter Follow](https://img.shields.io/twitter/follow/js_beautifier.svg?style=social&label=Follow)](https://twitter.com/intent/user?screen_name=js_beautifier)
[![NPM stats](https://nodei.co/npm/js-beautify.svg?downloadRank=true&downloads=true)](https://www.npmjs.org/package/js-beautify) [![Greenkeeper badge](https://badges.greenkeeper.io/beautify-web/js-beautify.svg)](https://greenkeeper.io/)
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](https://github.com/javascript-obfuscator/javascript-obfuscator).
Open [beautifier.io](https://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](https://github.com/beautify-web/js-beautify/blob/main/CONTRIBUTING.md) then fix an issue marked with the ["Good first issue"](https://github.com/beautify-web/js-beautify/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) 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](https://cdnjs.com/libraries/js-beautify) and rawgit.
To pull the latest version from one of these services include one set of the script tags below in your document:
```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.13.5/beautify.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.13.5/beautify-css.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.13.5/beautify-html.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.13.5/beautify.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.13.5/beautify-css.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.13.5/beautify-html.min.js"></script>
<script src="https://cdn.rawgit.com/beautify-web/js-beautify/v1.13.5/js/lib/beautify.js"></script>
<script src="https://cdn.rawgit.com/beautify-web/js-beautify/v1.13.5/js/lib/beautify-css.js"></script>
<script src="https://cdn.rawgit.com/beautify-web/js-beautify/v1.13.5/js/lib/beautify-html.js"></script>
```
Older versions are available by changing the version number.
Disclaimer: These are free services, so there are [no uptime or support guarantees](https://github.com/rgrove/rawgit/wiki/Frequently-Asked-Questions#i-need-guaranteed-100-uptime-should-i-use-cdnrawgitcom).
## 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
```
# 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](https://beautifier.io/). Options are available via the UI.
## Web Library
The script tags above expose three functions: `js_beautify`, `css_beautify`, and `html_beautify`.
## Node.js JavaScript
When installed globally, the beautifier provides an executable `js-beautify` script. The beautified result is sent to `stdout` unless otherwise configured.
```bash
$ js-beautify foo.js
```
To use `js-beautify` as a `node` library (after install locally), import and call the appropriate beautifier method for javascript (js), css, or html. All three method signatures are `beautify(code, options)`. `code` is the string of code to be beautified. options is an object with the settings you would like used to beautify the code.
The configuration option names are the same as the CLI names but with underscores instead of dashes. For example, `--indent-size 2 --space-in-empty-paren` would be `{ indent_size: 2, space_in_empty_paren: true }`.
```js
var beautify = require('js-beautify').js,
fs = require('fs');
fs.readFile('foo.js', 'utf8', function (err, data) {
if (err) {
throw err;
}
console.log(beautify(data, { indent_size: 2, space_in_empty_paren: true }));
});
```
## Python
After installing, to beautify using Python:
```bash
$ js-beautify file.js
```
Beautified output goes to `stdout` by default.
To use `jsbeautifier` as a library is simple:
```python
import jsbeautifier
res = jsbeautifier.beautify('your javascript string')
res = jsbeautifier.beautify_file('some_file.js')
```
...or, to specify some options:
```python
opts = jsbeautifier.default_options()
opts.indent_size = 2
opts.space_in_empty_paren = True
res = jsbeautifier.beautify('some javascript', opts)
```
The configuration option names are the same as the CLI names but with underscores instead of dashes. The example above would be set on the command-line as `--indent-size 2 --space-in-empty-paren`.
# Options
These are the command-line flags for both Python and JS scripts:
```text
CLI Options:
-f, --file Input file(s) (Pass '-' for stdin)
-r, --replace Write output in-place, replacing input
-o, --outfile Write output to file (default stdout)
--config Path to config file
--type [js|css|html] ["js"] Select beautifier type (NOTE: Does *not* filter files, only defines which beautifier type to run)
-q, --quiet Suppress logging to stdout
-h, --help Show this help
-v, --version Show the version
Beautifier Options:
-s, --indent-size Indentation size [4]
-c, --indent-char Indentation character [" "]
-t, --indent-with-tabs Indent with tabs, overrides -s and -c
-e, --eol Character(s) to use as line terminators.
[first newline in file, otherwise "\n]
-n, --end-with-newline End output with newline
--editorconfig Use EditorConfig to set up the options
-l, --indent-level Initial indentation level [0]
-p, --preserve-newlines Preserve line-breaks (--no-preserv
没有合适的资源?快使用搜索试试~ 我知道了~
HBuilderX.3.2.12.20211029.zip
共3084个文件
png:1528个
js:786个
json:249个
需积分: 10 0 下载量 175 浏览量
2021-11-20
11:10:23
上传
评论
收藏 24.05MB ZIP 举报
温馨提示
HBuilderX.3.2.12.20211029
资源详情
资源评论
资源推荐
收起资源包目录
HBuilderX.3.2.12.20211029.zip (3084个子文件)
0616e6967278a40222468f6921479fae95a782864f65cb27870684a3596bbb2c901c01c818d3493f93149e068e1b70a7fba6ef0b749c21c55fcb4befd67a 100KB
0c5a474f92863d2e97d0b9ca16a37261b487f7a82de9243ce7f32885b7bc2d7b063209ea0bab51fc7715c3f06dc4decce95418c4ad859d3b1a7e79cd826b 100KB
11a5167108e2019e2c4f5b49ecf8bb9efa1377d63f407fd1c71572749592b487374a0c32ad3c4173ed6fd2f7a26b6684a6294750c004b7248f7777ef5040 98KB
1341f626aed0605cf4d7025c15b6f31692c6bb5aee4947056af73568b3ec 776B
1572ea5dc6edb8e421f6d2e0323b7078b0b45714b22f2ef482424bd24fd39c7589198dee941b1d36492f97575553a974aa2f1bd9e040996a10083a24c20e 250KB
18e57036a3df89674cbdeca2ccd0b12f26b94f295880c67df9731395bfd8e8fb2f03c0666360d93d0ac7fef322e0e1d86beb6be3aea56ecf09f1836cf12a 112KB
1a70af0085502c7fd8b18feffae56c62cfa9494b22569252a8697d058946d80cac9251e7a2eb5dc7a0678082b8905fe8f603434f7a7daea308e4c476b70d 100KB
1a7244dabeacb63ddf1645736bd76bdaf1148ab0e031a65b81eb4f9bba04 776B
1c63eba31d011070342d7a466caedc8e90d82bd72decdb461ad3ba11dad5 776B
209d944c37ce57cc6cc61a0690a35530e62ad120220d556a3f13d431877e08217d45b55af069f62e99f5041a88ce3323ddaeb9bb9e0450ab5cf9b0465c3c 111KB
2313d380fdca893c3d325e303bea4f8503ef4b4372138e0078ced715605e 776B
2b412e43b7cb60aac9b8c6f8a3f8854cc068b0d91fc377100aac679d26c33c3b10ff29b086c7f447d8ea5f82e20851fcea1134d7deb81b8667ba65922415 100KB
304aa807b58c3fce33cc3abc6cf9e3dcb67db0879a11865812e9869be9cd2d9fa65b8d5cf1efc9e92a61f04ffe3d31825ffa8c938ee82a36a1684a5b229d 105KB
311fa34d124dd0c58cbcda99d09adcf70f76349c5e0a96386f3cdddb06fa 776B
3595de884393df7c15aa77f7ec3e09a190bf9bbbb79b9a1d82cbe701c5aaa540f9b0b1acbc768512da4d7ae380142abc82be7757ceb054b20d5a920ec59c 247KB
35fe5cb96dbaef9f1f88d158d28e1f37dc100ba60483f9c2605f11a463d1f35a869698415e313e859852205551ad4d4bce394571b64b7fd9418552051d62 100KB
3f1265a60e4717444697c7251701873f984ecb46127b2f6e52c9d18882b7 776B
46a54491521c4b61a25ca238238ebe4e822aa6e2f30fef59a448df9a23ebe7351cf9156d7585106fcea3ce5def535213ef0db0b0a5a211224e9f350143b9 104KB
5420b7d6cecec246d1211554ce8633874697a0ab7f8d85dbd38914686d3d4a87b889dd06bd8669ae3ef04e0a116ac6b3d5c2a49d519dc81d8c5020f81a26 251KB
563c6c191976f6eb338c0dd237a64a4dc11bd9bf8e42f9a65bf3abd69b4d 776B
56ad1ff38c6aecb5da24bb4c9b48bcfed90a44f741fbbc60abfefa92d512 776B
5808ee7a25f6f2cce27e67e81a6e6d55e49a158b91acc8ebdcbe935a71aa19e16dff7bb58a1a0c91d47a28d58fb9818c6016dd37c108728ab7fe88414d72 249KB
5950182fc962477260066758129d2e2da251761dc151b95ac627660bb3a2 776B
5f81a01c9f7673e7c09824671324ab32ed4af0631d2041e10f95c85fe28a9c5b89ddfae2236c0027bc6bca1ed29e1ae49ebd5056ccbb958ecd3d9e692a0d 248KB
62e77bca908b5d47c9ecc820ad1d9bd5e0e303aba0a072c0f3c5ef0a8cd625c424fab03f6f4bea079c082a3a4fea3e290d87dd6fa068190d1e7ec4bf7701 251KB
6b8fee38bf0056d461f24f29192cc49dfa9173ec4d507cdc31d5b479856907a6d86c0f6e4bd93322ce49d510af0c9398775bf4036cfe24a4b146bfb16d59 250KB
6c9767f247cd7b2ed20321f77f0c98292a9289b4a4e5ff35e119c3a4e4b896b4cf8ef07426e12c5b69755efea1b65f4c504f6cfa9981c528d31a66afc796 250KB
6ec9c293a3597e4653fe82a4d41be4c3a0d2b158c469670ed5a6497f3fd412c0d7848e4279938b0317b02f30992a62f9edddc43d5b537e207e4ae71893be 248KB
749386dca625d70319dc16e179df5e0460119a0649f52742fbb4c5cfbae1 776B
75415db9c5e648f3a11bf4c4f981559ae11c1e36e869556cdfb7c4e044f47eac0e2c9a504416e7e5505e6b90c191941d0ff28cfd20655bae53043760e07e 104KB
7e48a242fbefbf9d9bc45bd90e0939f9811d39fd079d1e98215089590e8a 776B
80008e9d951e492bbc885fb399255e70ef6aa606c3519c8a1a5b9dd37c9f 776B
84c80096134e309e2e31ee9a5e0d0e982461dc4413a5cd8a60e9809c28d1 776B
8c380afa49a04ea6988f1dda1fa0cce25764ae7c7e524e21bce712249546 776B
8dc73250c23f343abece8343210a9f18aec7796ac372917b6a885d8a8463 776B
96172b9e16fcb44b93bd65c79f77455b83bfad60a14c6d96390bc5ed7291 776B
a0021b76c13fbca09d842d6d455ece86ed44bee5ebd85adce6579ae3a6bf90a56b41c71bd57f82a61420f06bce2f67487925b41f0492cefa1e5cc31726ce 247KB
a165cd93d6ebd9de39225f35b1f8184263f57fc4b6502877f3842702b932f12826aeed1b921d943175d3b543084dd54d3b3635230154f95a9f9478a90514 104KB
a7a594a8adb9402d49920b6d126ca4cd38de4de45b2ea31a32fac417fbc0 776B
ab25e090abe2933b0fc43ca8b1a59e54672046cb74e0601d9b064fcece30 776B
adad6742c68715bc8c14b0c548bce19fc6efe406f111db89de5c27b3ef4d 776B
apply 179B
b00688ed02a18e2ae49d68a0a1806a8c1c070d5305ff3f6cc43be2bae614df647c3e1b98b1f6ddd054376dcd4199c2bef20656e28a8ca2fab1486299cd6b 248KB
b74e155ab042dbf3bd8ed2d73d91af11247fa47286738d55f1bd8593aa8f 776B
b785985c43fc2fd56551356ceb96aeec31e39df2f3e9a92840bbb93763ea474fbae9836421ff846aa28164a28288e72824f9a6d6467d2855c124d71377fa 104KB
b809ca35e55dfc16231494ce563dc3a0d8b3a2b5acdb86bdba2446505e11 776B
reset.bat 3KB
bc1691bee0b185e895de97696b373260ba31ec43074652946ac01a47c481 776B
range.bnf 619B
build 707B
c2155d2383abe169af3fced2b1aed93ea19147face5a9b6d0ce0e6bcf5af 776B
c2ddd28b32684686fb38a82a9f51f05efa498c50a5ed7b5de6cdd96d3cbf 776B
strip-json-comments.cmd 200B
shjs.cmd 180B
qt.conf 46B
default.css 0B
css-beautify 72B
d1b7c548ab8e826cb854d2887e489d169e07ac82ab273698eb4498fdad24 776B
d3c4b2247e899597ce36988c7918697c09d3f1845ab5a01298503f0039ab 776B
d5795d76a8fac4ca8fa398a971cf1ff9322bd869ec627927417c5202ad88 776B
d5b1b121d75c4d46ef7b3ad8d063b98b3837aa8ef64c2c072329989446d7 776B
d79befcea1dbc9e46eab2aa818bc74fa1b598412948797b24b23f806d36f 776B
dc72514446944c2137e104a57a8691f58d4725ced1472022ddcec1df067c2566e904ec46f67609c35a567f9e7bb7efa5164133361d845fef3b4dc14fe3da 250KB
df436f59e8e6d52d03e64706b0c0e806b0d70f6649ee152c5bec0b54d98b 776B
HBuilderX.dll 16.74MB
Qt5Gui.dll 4.78MB
Qt5Core.dll 4.43MB
Qt5Widgets.dll 4.23MB
libeay32.dll 1.21MB
qwindows.dll 987KB
msvcr120.dll 948KB
ucrtbase.dll 863KB
Qt5Network.dll 832KB
msvcp140.dll 429KB
qwebp.dll 315KB
qtiff.dll 309KB
ssleay32.dll 268KB
QuaZIP.dll 259KB
QuaZIP.dll 256KB
Qt5Svg.dll 250KB
qjpeg.dll 240KB
Qt5WinExtras.dll 231KB
Qt5Xml.dll 149KB
Qt5WebSockets.dll 108KB
vcruntime140.dll 83KB
api-ms-win-crt-private-l1-1-0.dll 63KB
qicns.dll 33KB
qsvgicon.dll 31KB
qico.dll 27KB
qgif.dll 26KB
api-ms-win-crt-math-l1-1-0.dll 22KB
api-ms-win-crt-multibyte-l1-1-0.dll 19KB
api-ms-win-crt-string-l1-1-0.dll 17KB
api-ms-win-crt-stdio-l1-1-0.dll 17KB
api-ms-win-crt-runtime-l1-1-0.dll 16KB
api-ms-win-crt-convert-l1-1-0.dll 15KB
api-ms-win-core-file-l1-1-0.dll 15KB
api-ms-win-core-localization-l1-2-0.dll 14KB
api-ms-win-crt-time-l1-1-0.dll 14KB
api-ms-win-crt-filesystem-l1-1-0.dll 13KB
共 3084 条
- 1
- 2
- 3
- 4
- 5
- 6
- 31
luck_wy
- 粉丝: 1
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0