Apache httpd Config Formatter
Format and re-indent Apache httpd.conf / VirtualHost configuration text. Nested <Directory>, <Location>, <IfModule> and other blocks get consistent indentation, one directive per line, with comments preserved.
Input
Formatting Options
Output
Guides
What this tool does
Apache configuration files — httpd.conf, apache2.conf, .conf files in sites-available/, or any snippet built from <VirtualHost>, <Directory>, <Location>, <IfModule> and similar blocks — quickly turn into a wall of inconsistent indentation once they've been copy-pasted, hand-edited, or merged from multiple sources. This tool reformats that text into clean, consistently indented configuration: every nested block gets indented one level deeper than its parent, one directive per line, with comments left exactly as written, just moved to the correct indentation.
It's a line-based formatter, not a full Apache config validator — it doesn't check directive syntax or verify a block type is valid. It focuses on what actually makes configs hard to read: indentation and spacing.
How to use it
- Paste your Apache configuration into the Apache Config box, or upload a
.conffile directly. - Choose an Indent Size — 2 or 4 spaces per nesting level (4 is the default and matches most Apache examples in the wild).
- The formatted result appears instantly in the Formatted Config panel. Copy it or download it as
httpd.conf.
Formatting happens automatically as you type or edit the input — there's no button to click.
How the indentation logic works
The formatter reads your config line by line and tracks a nesting depth counter. A line that opens a block, like <VirtualHost *:80> or <Directory /var/www/html>, is indented at the current depth, then depth increases by one for the lines that follow. A line that closes a block, like </VirtualHost>, first decreases the depth by one, then is indented at that new, shallower depth — so the closing tag lines up with its opener. Ordinary directive lines (ServerName example.com) are indented at the current depth, with doubled-up spacing between the directive name and its arguments collapsed to a single space. Comment lines (#...) are re-indented but otherwise left untouched. Blank lines are preserved as-is.
If a block is left unclosed, or a closing tag appears with no matching opener, the formatter never errors — depth simply stops decreasing once it reaches zero, so the rest of the file still formats sensibly.
FAQ
Does this validate my Apache config?
No. It only reformats indentation and whitespace; it doesn't check module availability or directive syntax. Use apachectl configtest (or httpd -t) on your server for that.
Will it change my directive values, IPs, or paths? No. Arguments are left exactly as written — only whitespace between a directive name and its arguments is normalized to a single space.
Does it work with Nginx configs?
No — Nginx uses { } blocks instead of Apache's <Tag>...</Tag> syntax.
Can I use tabs instead of spaces? The tool offers 2-space or 4-space indentation, the two most common Apache conventions.
Privacy
This tool runs entirely in your browser. Your configuration text — including hostnames, file paths, and any credentials that might appear in it — is never uploaded to a server.
Use it from code
From 3 credits per callREST API
curl -X POST https://api.iotools.cloud/v1/tool/apache-httpd-config-formatter \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"inputConfig": "# Main config\n<VirtualHost *:80>\n ServerName …",
"indentSize": "4"
}'Swap in your own key from your account. The tool's fields are the body — no wrapper.
Ask an AI agent
Use the IOTools `apache-httpd-config-formatter` tool (Apache httpd Config Formatter) on this input:
YOUR_INPUT_HEREPaste this at any agent connected to the IOTools MCP server, then add your input.