Skip to content
nginx config file formatter/beautifier written in Python.
Branch: master
Clone or download

nginx config file formatter

This Python script formats nginx configuration files in consistent way, described below:

  • all lines are indented in uniform manner, with 4 spaces per level
  • neighbouring empty lines are collapsed to at most two empty lines
  • curly braces placement follows Java convention
  • whitespaces are collapsed, except in comments an quotation marks
  • whitespaces in variable designators are removed: ${ my_variable } is collapsed to ${my_variable}


Python 3.2 or later is needed to run this program. The simplest form of installation would be copying to your scripts directory.

You can also clone the repository and symlink the executable:

git clone
ln -s ~/nginx-config-formatter/ ~/bin/


usage: [-h] [-v] [-b] config_files [config_files ...]

Script formats nginx configuration file.

positional arguments:
  config_files          configuration files to format

optional arguments:
  -h, --help            show this help message and exit
  -v, --verbose         show formatted file names
  -b, --backup-original
                        backup original config file


Copyright 2016 Michał Słomkowski @ 1CONNECT. License: Apache 2.0.

You can’t perform that action at this time.