A comprehensive code beautification library for JavaScript, CSS, and HTML with extensive formatting options and cross-platform support
—
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Pending
The risk profile of this skill
Command-line tools for each beautifier supporting file processing, glob patterns, and configuration files. Provides comprehensive CLI access to all beautification features with support for stdin/stdout processing and batch operations.
Command-line interface for JavaScript beautification with file processing and configuration support.
# Basic usage
js-beautify [options] <file1> [file2] ...
# Common CLI options
js-beautify -f file.js # Beautify specific file
js-beautify -f file1.js file2.js # Multiple files
js-beautify -r -f *.js # Replace files in-place
js-beautify -o output.js -f input.js # Write to output file
js-beautify < input.js > output.js # Stdin/stdout processing
js-beautify --config .jsbeautifyrc -f file.js # Use config file
# 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] Select beautifier type
-q, --quiet Suppress logging to stdout
-h, --help Show help
-v, --version Show versionCommand-line interface for CSS beautification.
# Basic usage
css-beautify [options] <file1> [file2] ...
# Examples
css-beautify -f styles.css
css-beautify -r -f *.css # In-place replacement
css-beautify -s 2 -f input.css # 2-space indentation
css-beautify --brace-style expand -f style.cssCommand-line interface for HTML beautification with template support.
# Basic usage
html-beautify [options] <file1> [file2] ...
# Examples
html-beautify -f index.html
html-beautify -r -f *.html # Batch processing
html-beautify --wrap-attributes force -f template.html
html-beautify --templating handlebars -f template.hbs# Input/Output
-f, --file FILE Input file(s), use '-' for stdin
-r, --replace Write output in-place, replacing input files
-o, --outfile FILE Write output to specific file (default: stdout)
# Configuration
--config FILE Path to JSON configuration file
--type TYPE Force beautifier type [js|css|html]
# Output Control
-q, --quiet Suppress logging output
-h, --help Show help message
-v, --version Show version informationUsage Examples:
# Process stdin to stdout
echo 'function test(){return 1;}' | js-beautify
# Process file to stdout
js-beautify -f ugly.js
# Process multiple files, output to stdout
js-beautify -f file1.js file2.js
# Replace files in-place
js-beautify -r -f *.js
# Use custom output file
js-beautify -f input.js -o beautified.js
# Quiet mode (no progress output)
js-beautify -q -f file.js# Indentation
-s, --indent-size SIZE Indentation size [4]
-c, --indent-char CHAR Indentation character [" "]
-t, --indent-with-tabs Indent with tabs, overrides -s and -c
-l, --indent-level LEVEL Initial indentation level [0]
# Line endings
-e, --eol STRING Character(s) to use as line terminators
-n, --end-with-newline End output with newline
--editorconfig Use EditorConfig to set up options
# Newlines and whitespace
-p, --preserve-newlines Preserve line-breaks (--no-preserve-newlines disables)
-m, --max-preserve-newlines N Number of line-breaks to preserve in one chunk [10]
-w, --wrap-line-length N Wrap lines that exceed N characters [0]
--indent-empty-lines Keep indentation on empty lines
# JavaScript-specific
-P, --space-in-paren Add padding spaces within paren, ie. f( a, b )
-E, --space-in-empty-paren Add single space inside empty paren, ie. f( )
-j, --jslint-happy Enable jslint-stricter mode
-a, --space-after-anon-function Add space before anonymous function's parens
--space-after-named-function Add space before named function's parens
-b, --brace-style STYLE Brace style [collapse|expand|end-expand|none][,preserve-inline]
-u, --unindent-chained-methods Don't indent chained method calls
-B, --break-chained-methods Break chained method calls across subsequent lines
-k, --keep-array-indentation Preserve array indentation
-x, --unescape-strings Decode printable characters encoded in xNN notation
-X, --e4x Pass E4X xml literals through untouched
-C, --comma-first Put commas at beginning of new line instead of end
-O, --operator-position POS Set operator position (before-newline|after-newline|preserve-newline)
--good-stuff Warm the cockles of Crockford's heart
--templating LANGS List of templating languages (auto,django,erb,handlebars,php,smarty,angular)# Basic formatting
-s, --indent-size SIZE Indentation size [4]
-c, --indent-char CHAR Indentation character [" "]
-t, --indent-with-tabs Indent with tabs, overrides -s and -c
-e, --eol STRING Character(s) to use as line terminators
-n, --end-with-newline End output with newline
# CSS-specific
-b, --brace-style STYLE Brace style [collapse|expand]
-L, --selector-separator-newline Add newline between multiple selectors
-N, --newline-between-rules Add newline between CSS rules
--indent-empty-lines Keep indentation on empty lines# Basic formatting
-s, --indent-size SIZE Indentation size [4]
-c, --indent-char CHAR Indentation character [" "]
-t, --indent-with-tabs Indent with tabs, overrides -s and -c
-e, --eol STRING Character(s) to use as line terminators
-n, --end-with-newline End output with newline
# Newlines
-p, --preserve-newlines Preserve existing line-breaks
-m, --max-preserve-newlines N Maximum number of line-breaks to preserve [10]
# HTML structure
-I, --indent-inner-html Indent <head> and <body> sections
-b, --brace-style STYLE Brace style [collapse-preserve-inline|collapse|expand|end-expand|none]
-S, --indent-scripts MODE Script indentation [keep|separate|normal]
# Line wrapping
-w, --wrap-line-length N Maximum characters per line (0 disables) [250]
-A, --wrap-attributes MODE Wrap attributes to new lines [auto|force|force-aligned|force-expand-multiline|aligned-multiple|preserve|preserve-aligned]
-M, --wrap-attributes-min-attrs N Minimum attributes for force wrap [2]
-i, --wrap-attributes-indent-size N Indent wrapped attributes to after N characters
# Element handling
-d, --inline TAGS List of tags to be considered inline tags
--inline_custom_elements Inline custom elements [true]
-U, --unformatted TAGS List of tags that should not be reformatted
-T, --content_unformatted TAGS List of tags whose content should not be reformatted
-E, --extra_liners TAGS List of tags that should have extra newline before them
--unformatted_content_delimiter STR Keep text content together between this string
--indent-empty-lines Keep indentation on empty lines
--templating LANGS List of templating languages (auto,none,django,erb,handlebars,php,smarty,angular)Use JSON files for complex configuration:
{
"indent_size": 2,
"brace_style": "expand",
"preserve_newlines": true,
"max_preserve_newlines": 2,
"wrap_line_length": 80
}Usage:
js-beautify --config beautify-config.json -f file.jsAutomatically loaded from current directory or parent directories:
{
"indent_size": 2,
"end_with_newline": true,
"js": {
"brace_style": "expand"
},
"css": {
"newline_between_rules": false
},
"html": {
"wrap_attributes": "force"
}
}# In-place beautification of all JS files
find . -name "*.js" -not -path "./node_modules/*" | xargs js-beautify -r
# Using glob patterns (if shell supports)
js-beautify -r -f src/**/*.js# Beautify with different settings per file type
js-beautify --indent-size 2 --brace-style expand -r -f src/*.js
css-beautify --indent-size 4 --newline-between-rules -r -f styles/*.css
html-beautify --wrap-attributes force --indent-size 2 -r -f templates/*.html# Process through pipeline
curl -s https://example.com/ugly.js | js-beautify | tee beautiful.js
# Combine with other tools
js-beautify -f ugly.js | grep -v "console.log" > clean.js0 - Success1 - Error during processing2 - Invalid command line arguments# Invalid brace style
js-beautify --brace-style invalid -f file.js
# Error: Invalid Option Value: The option 'brace_style' can only be one of...
# File not found
js-beautify -f nonexistent.js
# Error: ENOENT: no such file or directory
# Permission denied
js-beautify -r -f /root/protected.js
# Error: EACCES: permission denied# Enable debug output
DEBUG_JSBEAUTIFY=1 js-beautify -f file.js
# Or use environment variable
export JSBEAUTIFY_DEBUG=1
js-beautify -f file.js