# JS Beautifier

[](https://pypi.python.org/pypi/jsbeautifier)
[](https://cdnjs.com/libraries/js-beautify)
[](https://www.npmjs.com/package/js-beautify)
[](https://www.npmjs.com/package/js-beautify?activeTab=versions)
[](https://gitter.im/beautify-web/js-beautify?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[](https://twitter.com/intent/user?screen_name=js_beautifier)
[](https://www.npmjs.org/package/js-beautify) [](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.6.4.20220922.zip
需积分: 0 63 浏览量
更新于2022-09-30
收藏 32.38MB ZIP 举报
《HBuilderX:轻量与强大的HTML5开发神器》
HBuilderX,简称为HX,是HTML5开发领域的一款高效工具,它集编辑器的轻便性和集成开发环境(IDE)的强大功能于一体,旨在为开发者提供更为流畅的编程体验。这款软件的名字由“H”(HTML的首字母)和“Builder”(构建者)以及代表进化的“X”组成,寓意着它是HBuilder系列的升级版,具备更先进的特性和优化。
HBuilderX的核心优势在于其独特的设计理念。它采用了先进的文本编辑技术,使得代码编写速度大幅提升,同时提供了丰富的代码提示和自动完成功能,帮助开发者快速准确地编写代码。对于HTML、CSS、JavaScript等前端语言的支持尤为出色,极大地提高了开发效率。此外,HBuilderX还支持Vue.js、React.js、Angular等主流前端框架,使得全栈开发变得更加便捷。
在项目管理方面,HBuilderX拥有完善的工程组织结构,支持多项目并行开发,可以方便地管理各种资源文件,如图片、字体、音频等。它内置了实时预览功能,可以在编写代码的同时查看页面效果,大大减少了反复编译和刷新浏览器的操作。此外,HBuilderX还提供了一键打包、部署功能,让开发者能够快速将项目发布到各种平台,如Web、移动端和桌面应用。
HBuilderX的特色功能还包括Markdown写作、Git版本控制、插件扩展、代码检查和修复、性能分析等。Markdown支持让非程序员也能轻松撰写技术文档,Git集成则为团队协作提供了强大的版本管理工具。丰富的插件库允许用户根据自己的需求定制工作环境,提升个性化开发体验。代码检查和修复功能则能帮助开发者遵循最佳实践,提高代码质量。
在性能方面,HBuilderX注重用户体验,力求做到启动速度快、占用资源少。其轻量级的设计使得即使在较低配置的电脑上也能流畅运行。同时,它还不断进行优化,确保在处理大型项目时也能保持稳定的性能表现。
HBuilderX作为一款专业且全面的HTML5开发工具,凭借其强大的编辑功能、高效的项目管理和丰富的辅助工具,已经成为许多前端开发者不可或缺的得力助手。无论是初学者还是资深开发者,都能在HBuilderX中找到适合自己的开发方式,实现快速、高效的代码编写,从而在Web开发的世界里游刃有余。

qxmjava
- 粉丝: 25
最新资源
- 2025年鸡舍正压过滤(FAPP)通风设备项目大数据研究报告(1).docx
- 简述计算机网络发展方向(1).docx
- Java课程设计扫雷.doc
- Web页面设计规范(很好好权威).ppt
- 教育信息化发展历程存在问题及未来趋势PPT课件(1).pptx
- 2023年pmp知识点整理VDOC.doc
- 软件公司内部管理制度 (1)(1).docx
- 精品专题资料2021-2022年收藏互联网品牌运营的策划方案概要(1).doc
- HPLC法测定脑心清片浸膏中原儿茶酸的含量.docx
- 完整版电子商务概论A卷(1).doc
- PLC项目化教程任务一配置PPI网络通信.pptx
- 长江大学photoshop结业作业答案(1).docx
- C语言课程设计个人课程表管理系统报告.docx
- EXCEL-VBAProject保护密码破解查看见过较详细的操作.doc
- 完整word版南京大学操作系统-2013A(1).doc
- 2025年炮塔式铣床项目大数据研究报告(1).docx