Linux command
js-beautify 命令
文件
复制后可按需替换文件名、目录或参数。
常用示例
Beautify JavaScript file
js-beautify [file.js]
Beautify and save in place
js-beautify -r [file.js]
Beautify HTML
html-beautify [file.html]
Beautify CSS
css-beautify [file.css]
Set indentation
js-beautify -s [4] [file.js]
Use tabs
js-beautify -t [file.js]
Output to file
js-beautify [input.js] -o [output.js]
说明
js-beautify formats JavaScript, HTML, and CSS files with consistent indentation and style. It's useful for cleaning up minified code or enforcing consistent formatting. The tool provides separate commands for each language (js-beautify, html-beautify, css-beautify) or auto-detects based on extension.
参数
- -r, --replace
- Replace file in place.
- -o _file_
- Output to file.
- -s _size_
- Indent size (default 4).
- -t, --indent-with-tabs
- Use tabs.
- -e, --eol _chars_
- End of line character.
- -n, --end-with-newline
- End with newline.
- --type _type_
- Force type: js, html, css.
- -f _file_
- Input file.
- --config _file_
- Configuration file.
FAQ
What is the js-beautify command used for?
js-beautify formats JavaScript, HTML, and CSS files with consistent indentation and style. It's useful for cleaning up minified code or enforcing consistent formatting. The tool provides separate commands for each language (js-beautify, html-beautify, css-beautify) or auto-detects based on extension.
How do I run a basic js-beautify example?
Run `js-beautify [file.js]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -r, --replace do in js-beautify?
Replace file in place.