The Python
cssbeautifier package is a separate install from the JavaScript beautifier. Install it with pip install cssbeautifier. The Node.js js-beautify package includes the CSS beautifier.Before and after
Key options
brace_style
Controls brace placement. Only collapse and expand are implemented for CSS.
| Value | Description |
|---|---|
collapse | Opening brace on same line as selector (default) |
expand | Opening brace on its own line |
- collapse (default)
- expand
selector_separator_newline
When true (default), places each selector in a multi-selector rule on its own line.
- selector_separator_newline: true (default)
- selector_separator_newline: false
newline_between_rules
When true (default), adds a blank line between CSS rule blocks.
- newline_between_rules: true (default)
- newline_between_rules: false
indent_size and indent_char
indent_size sets the number of characters per indentation level. indent_char sets the character used for indentation. Use indent_with_tabs: true to indent with tabs instead.
indent_size: 2:
All CSS-specific options at a glance
brace_style
brace_style
Default:
Values:
"collapse"Values:
collapse, expandControls placement of opening braces relative to selectors.selector_separator_newline
selector_separator_newline
Default:
truePlace each selector in a multi-selector rule on its own line.newline_between_rules
newline_between_rules
Default:
trueInsert a blank line between CSS rule blocks.space_around_combinator
space_around_combinator
Default:
falseAdd spaces around CSS combinators such as >, ~, and +.indent_size
indent_size
Default:
4Number of characters per indentation level.indent_char
indent_char
Default:
" " (space)Character used for indentation.indent_with_tabs
indent_with_tabs
Default:
falseIndent with tabs. Overrides indent_size and indent_char.end_with_newline
end_with_newline
Default:
falseEnd output with a trailing newline.indent_empty_lines
indent_empty_lines
Default:
falseKeep indentation on otherwise empty lines.Usage
- Node.js
- CLI
- Python