jsbeautify_-prefixed environment variables- A JSON file specified with
--config <path> - A
.jsbeautifyrcfile found at any directory level from$PWDupward
This automatic config loading is JavaScript-only. The Python
jsbeautifier package reads options passed directly to the API and does not look for a .jsbeautifyrc file..jsbeautifyrc file
Create a.jsbeautifyrc file in your project root (or any ancestor directory). The beautifier searches from the current working directory upward until it finds one.
The file must contain valid JSON. Option names use underscores, matching the library API.
selector_separator_newline only when beautifying CSS. See Language-specific overrides for the full inheritance model.
—config flag
Point to any JSON file using the--config flag:
.jsbeautifyrc.
Environment variables
Prefix any option name withjsbeautify_ to set it as an environment variable:
indent_size are parsed to integers automatically. Boolean values accept true or false.
Priority order
When multiple configuration sources define the same option, the following precedence applies (highest first):| Source | Priority |
|---|---|
CLI flags (e.g. --indent-size 4) | Highest |
jsbeautify_-prefixed environment variables | High |
--config file | Medium |
.jsbeautifyrc (nearest ancestor) | Low |
| Built-in defaults | Lowest |
Minimal example
A typical.jsbeautifyrc for a project using 2-space indentation and a trailing newline:
js-beautify without any additional flags: