js, css, or html key. You can also override options for JavaScript and CSS embedded inside HTML by nesting them under html.js and html.css.
How it works
When beautifying a file, the library merges the top-level options with the language-specific overrides. The language node wins on any key it defines; all other keys fall through from the top level. This works:- In
.jsbeautifyrcand--configfiles in the JavaScript implementation. - When passing an options object directly to the API in both the JavaScript and Python implementations.
In the Python implementation, language override nodes work only when you pass options directly to the API. The Python CLI does not read
.jsbeautifyrc files.Example
What this config does
HTML files inheritindent_size: 4 from the top level. The html.end_with_newline: true setting applies only to HTML output.
JavaScript and CSS embedded in HTML both inherit end_with_newline: true from the html node. They override their indentation to 2 spaces via html.js.indent_size and html.css.indent_size.
Standalone CSS files use indent_size: 1 from the css node, overriding the top-level 4.
Standalone JavaScript files inherit indent_size: 4 from the top level and set preserve_newlines: true from the js node.
Supported override nodes
| Node path | Applies to |
|---|---|
| (top level) | All languages |
js | Standalone JavaScript files |
css | Standalone CSS files |
html | Standalone HTML files |
html.js | JavaScript embedded inside HTML |
html.css | CSS embedded inside HTML |