# 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
没有合适的资源?快使用搜索试试~ 我知道了~
HBuilder安装包
共2945个文件
png:1569个
js:703个
json:261个
需积分: 4 3 下载量 118 浏览量
2022-09-10
20:41:40
上传
评论
收藏 32.23MB ZIP 举报
温馨提示
hbuilder最新版是款适合编程人员使用的编程工具。hbuilder通过完整的语法提示和代码输入法、代码块等,大幅提升HTML、js、css的开发效率。同时hbuilder还包括最全面的语法库和浏览器兼容性数据。该安装包是最新版本3.5.3,需要的伙伴可以自取~
资源详情
资源评论
资源推荐
收起资源包目录
HBuilder安装包 (2945个子文件)
apply 179B
reset.bat 3KB
range.bnf 619B
build 707B
strip-json-comments.cmd 200B
shjs.cmd 180B
qt.conf 46B
default.css 0B
css-beautify 72B
HBuilderX.dll 19.05MB
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-core-synch-l1-1-0.dll 13KB
api-ms-win-core-processthreads-l1-1-0.dll 13KB
api-ms-win-crt-filesystem-l1-1-0.dll 13KB
api-ms-win-core-sysinfo-l1-1-0.dll 12KB
api-ms-win-crt-conio-l1-1-0.dll 12KB
api-ms-win-core-processenvironment-l1-1-0.dll 12KB
api-ms-win-crt-process-l1-1-0.dll 12KB
api-ms-win-crt-heap-l1-1-0.dll 12KB
api-ms-win-crt-environment-l1-1-0.dll 12KB
api-ms-win-crt-locale-l1-1-0.dll 12KB
api-ms-win-core-synch-l1-2-0.dll 12KB
api-ms-win-core-memory-l1-1-0.dll 12KB
api-ms-win-crt-utility-l1-1-0.dll 12KB
api-ms-win-core-libraryloader-l1-1-0.dll 12KB
api-ms-win-core-heap-l1-1-0.dll 12KB
api-ms-win-core-interlocked-l1-1-0.dll 12KB
api-ms-win-core-processthreads-l1-1-1.dll 12KB
api-ms-win-core-console-l1-1-0.dll 12KB
api-ms-win-core-handle-l1-1-0.dll 11KB
api-ms-win-core-datetime-l1-1-0.dll 11KB
api-ms-win-core-errorhandling-l1-1-0.dll 11KB
api-ms-win-core-file-l1-2-0.dll 11KB
api-ms-win-core-timezone-l1-1-0.dll 11KB
api-ms-win-core-string-l1-1-0.dll 11KB
api-ms-win-core-debug-l1-1-0.dll 11KB
api-ms-win-core-util-l1-1-0.dll 11KB
api-ms-win-core-namedpipe-l1-1-0.dll 11KB
api-ms-win-core-file-l2-1-0.dll 11KB
api-ms-win-core-profile-l1-1-0.dll 11KB
api-ms-win-core-rtlsupport-l1-1-0.dll 11KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
editorconfig 78B
editorconfig 78B
node.exe 24.1MB
HBuilderX.exe 3.16MB
cli.exe 209KB
Updater.exe 82KB
uac.exe 24KB
loading.gif 38KB
loading_cloudspace.gif 27KB
loading_cloudspace.gif 27KB
loading_cloudspace.gif 27KB
waiting.gif 5KB
waiting.gif 5KB
waiting.gif 5KB
.gitattributes 67B
Attributes.html 503B
mui html.html 374B
index.html 270B
index.html 170B
共 2945 条
- 1
- 2
- 3
- 4
- 5
- 6
- 30
沃和莱特
- 粉丝: 1447
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0