Skip to main content

Nginx Config Formatter

Format and re-indent nginx configuration files. Nested http, server, location, upstream and other blocks get consistent indentation and one directive per line, with quoted values and comments preserved.

Input

Drop a file or browse
One file · text
Or

Formatting Options

Output

Formatted Config
 
Was this helpful?

Guides

The Nginx Config Formatter cleans up and re-indents nginx configuration files so their block structure is easy to read. Paste an nginx.conf, a site config from sites-available/, or any snippet, and get back consistent indentation with one directive per line — nested http, server, location, upstream, map, events and other brace-delimited blocks are indented to their true depth.

How to use it

  1. Paste your nginx configuration into the input box (or upload a config file).
  2. Adjust the formatting options if you want something other than the defaults.
  3. The formatted result appears instantly on the right, ready to copy or download as nginx.conf.

Formatting options

  • Indent Style — 2 spaces, 4 spaces, or a tab per nesting level. Nginx's own examples use 4 spaces, which is the default.
  • Brace Style — keep the opening brace on the same line as the directive (server {) or push it to the next line.
  • Semicolon Spacing — no space before the terminating ; (standard) or a space before it.
  • Normalize comments — ensure a single space after # on comment lines (a shebang-style #! is left untouched).
  • Remove extra blank lines — collapse runs of blank lines and drop leading/trailing blank lines.
  • Align directive values — line up the values of consecutive directives at the same indent level into a neat column.

How it works

The formatter tokenizes the config character by character before re-indenting, so braces and semicolons that appear inside quoted strings or comments are never mistaken for structure. It then walks the resulting statements, increasing the indent depth after each block opens ({) and decreasing it before each block closes (}). Quoted values, regex location matchers, and variables like $host are preserved exactly as written.

This tool only reformats — it never reorders directives or changes their meaning, so running it on already-formatted config is safe and idempotent.

Does it validate my nginx config?

No. This is a formatter, not a linter or syntax checker. It reindents whatever you paste, even if the config has unbalanced braces or missing semicolons (stray closing braces are handled gracefully rather than throwing). Always test with nginx -t before reloading in production.

Is my configuration uploaded anywhere?

No. Formatting runs entirely in your browser — your configuration never leaves your device.

nginxconfigweb serverformatterbeautifyindent

Love the tools? Lose the ads.

One payment clears every ad from your account, for good. No subscription, no tracking.