INI formatter
Format and validate INI config files: unify separators (= or :) and their spacing, normalize indentation, collapse stray blank lines, sort sections and keys, keep or drop comments, and flag invalid lines with their line numbers.
Runs in your browserEvery computation happens in your browser — your data never leaves this device.
What this tool does
- Normalise a config file whose separators are all over the place (key=value in some lines, key: value in others) before committing so the diff stays readable.
- Fix inconsistent blank lines and trailing whitespace in one pass instead of producing a diff full of cosmetic noise.
- Sort sections and keys so two environments can be compared line by line and the real differences pop out.
- Validate a config: any line that is neither a section nor a key/value pair is reported with its line number, and duplicate keys can fail the run outright.
Example
Input
name : app [server] host=localhost [log] level: info
Output
name: app [server] host = localhost [log] level: info
With the defaults: separators keep their original style (colons stay colons, equals stays equals), one space is added around each separator, sections are separated by exactly one blank line, stray blank lines are removed and a trailing newline is added. Note the section-less name key stays in the default block, whose [default] header is not printed.
Frequently asked questions
Where do keys without a section go?
They land in a virtual section named default, which always sorts first and whose [default] header is never printed (the source had none). If a file contains both bare keys and an explicit [default] section, they are merged into the same block.
How are duplicate keys handled?
By default they are kept, and the result lists them (as section.key, e.g. server.port) with a count. "Keep the last one" drops the earlier definitions and reports how many lines were removed. "Report error" refuses to format the file at all — useful in CI to stop configuration from being silently overridden.
Which line does a comment attach to?
A comment follows whatever comes next: above a [section] header it becomes part of that section, above a key it precedes that key, and comments at the end of the file stay with the last section. Unchecking "keep comments" drops them all, though the comment line count is still reported.
How does minify differ from formatting?
Minify builds on the formatter but forces =, no spaces, no indentation, no blank lines between sections and no comments — good for machine-read compact configs. Section headers are still kept; only the cosmetic formatting is gone.
Which lines are considered invalid?
A line starting with [ that is not a valid [section], or that has an empty name, fails as an invalid section header. A line with neither = nor : fails as neither a section nor a key/value pair. An empty key such as "= value" fails as an empty key. All three report the exact line number so you can jump straight to it.
Keywords:iniini formatterini 格式化ini 美化配置文件config filesectionsort keys格式化lint