Nginx Config Formatter

Re-indent Nginx configuration block by block

Runs in your browserUtility01Formatters & Validators

What is Nginx Config Formatter?

An Nginx config formatter re-indents by brace nesting, puts each directive on its own line, and checks that the braces balance. It is ideal for cleaning up compressed configs copied out of tutorials or support tickets, and it runs locally in your browser.

How to use Nginx Config Formatter

  1. 1Paste an nginx.conf or a server block fragment.
  2. 2Choose 2- or 4-space indentation; the Nginx community convention is 4.
  3. 3The footer tells you whether the braces balance, and you should repair the structure first if they do not.
  4. 4Once it is tidy, run nginx -t for real syntax validation.

How do I do this in code?

Use the tool above for one-off work; for anything you repeat, move it into a script or your project.

# Validate the configuration syntax (this step cannot run in a browser)
nginx -t

# Reload gracefully once validation passes
nginx -s reload

Frequently asked questions

Does this tool check whether my configuration is correct?+

No. It only re-indents based on braces and semicolons, and verifies that the braces balance. Directive spelling, argument validity, and module availability all have to be checked with nginx -t on the server.

Why does Nginx still fail to start after reformatting?+

Indentation has no effect on meaning, so a startup failure always comes from the configuration itself. The usual culprits are a directive placed in the wrong context (an http-only directive written inside a server block, for example), a path that does not exist, or a port already in use.

Related tools

All tools