
Security News
ECMAScript 2025 Finalized with Iterator Helpers, Set Methods, RegExp.escape, and More
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
nginx-config-formatter
Advanced tools
A formatter for Nginx config files. Both API and CLI are available.
Features from nginxbeautifier
Plus we have:
{
or before }
are trimmednpm i -g nginx-config-formatter
Or
pnpm i -g nginx-config-formatter
nginx-config-formatter -p /etc/nginx
available options:
-p, --path (required) the path of files to be formatted. Support glob syntax
-h, --help display usage help
-i, --indentStyle style of indentation, space or tab, defaults to space
-c, --dontJoinCurlyBracket if true, the opening bracket starts with a new line, defaults to false
-a, --align align the values of all directives in the same block, defaults to false
-l, --trailingBlankLines Append a trailing blank line after the opening bracket, defaults to false
-ext, --extension the file extension of nginx config files, defaults to conf
formatFile(path: string, options?: OptionType): Promise<void>
path
can be the path of a .conf
file, or a folder contains .conf
file. Glob syntax is also supported. If a folder is provided, all .conf
files including those in its sub folders will be formatted.
formatContent(content: string, options?: OptionType): string
content
is the full content of a config file. Returns a string of the formatted content.
The APIs above accepts a option object. All options are optional and its default value is the same as the CLI.
interface OptionType {
indentStyle?: 'space' | 'tab'
dontJoinCurlyBracket?: boolean
align?: boolean
trailingBlankLines?: boolean
extension?: string
}
import { formatFile } from 'nginx-config-formatter'
formatFile('/etc/nginx', {
indentStyle: 'tab'
})
See CHANGELOG
This project is inspired by nginxbeautifier and use some of its code.
If you found it useful somehow, I would be grateful if you could leave a star in the project's GitHub repository.
Thank you.
FAQs
A formatter for Nginx config files
We found that nginx-config-formatter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.