INI File Formatter

Paste an INI file to tidy its spacing, group sections and catch broken headers. Comments, quoted values and continuation lines come through untouched.

Input

Settings

History

Load from URL

Where INI files still show up

INI is the oldest config format most developers touch every week: php.ini, MySQL’s my.cnf, .gitconfig, .editorconfig, Python’s setup.cfg and tox.ini, systemd units and Linux .desktop launchers all use it. There is no single standard, so every parser accepts a slightly different dialect. This formatter aims for the common ground: [section] headers, key = value or key: value pairs, comments starting with ; or #, and bare flags such as skip-name-resolve that have no value at all.

How to use it

Paste the file or drop it onto the input pane. The format is detected automatically, and the output updates as you type. Press Ctrl/Cmd+Enter to format on demand, Ctrl/Cmd+Shift+C to copy the result, or open the command palette with Ctrl/Cmd+K to switch format or toggle options by name. The Tree view shows sections as objects and keys as strings, which is handy for checking what a parser will actually read. The built-in INI parser and printer runs entirely in your browser, so database passwords in a my.cnf never leave your machine.

Options

  • Align = signs within a section pads keys so the separators line up in a column. Alignment is calculated per section, so one long key in [PHP] does not push every other section to the right.
  • Spaces around = writes key = value when on and key=value when off. Turn it off for tools that are strict about whitespace, such as some Windows .inf readers. Colon separators keep their colon; only the spacing changes.
  • Sort keys (in the toolbar) orders keys alphabetically inside each section. Section order is never changed, because some programs read sections top to bottom and the first match wins.
  • Indent only matters for files whose keys were indented in the input, such as .gitconfig, and for continuation lines.

What the formatter keeps exactly as written

Values are never rewritten. Quotes stay where you put them, so date.timezone = "Asia/Singapore" keeps its quotes, and an unquoted path with spaces stays unquoted. Inline comments after a value are kept when the ; or # is preceded by a space; a # glued to a value, as in color=#ff0000, is treated as part of the value. Lines indented deeper than the key above them are continuation lines (the configparser style used in setup.cfg), and they stay attached to that key. Comments directly above a section header move with the header, runs of blank lines collapse to one, and a UTF-8 byte-order mark is stripped with a note. MySQL’s !include lines are preserved in place.

Gotchas worth knowing

Duplicate keys are legal in some dialects and an error in others. PHP and most parsers let the last value win, Python’s configparser raises an error, and git config treats repeated keys as a list. The formatter warns on duplicates with the line of the first definition instead of guessing which you meant. Repeated section headers get the same warning. Keys are compared case-insensitively for this check, matching how configparser and Windows read them. Keys that appear before any header belong to an unnamed global section, which PHP accepts and configparser does not.

Examples

php.ini excerpt with uneven spacing

Separators are aligned per section and a blank line is added between sections, while the quoted time zone is left alone.

Input
[PHP]
engine=On
short_open_tag  =   Off
memory_limit=256M
upload_max_filesize = 32M
[Date]
date.timezone = "Asia/Singapore"
Output
[PHP]
engine              = On
short_open_tag      = Off
memory_limit        = 256M
upload_max_filesize = 32M

[Date]
date.timezone = "Asia/Singapore"
Open this example in the tool

Git config with indented keys

Indented keys stay indented, and the extra spaces inside the remote section header are collapsed.

Input
[user]
	name = Aisha Tan
	email = [email protected]
[remote   "origin"]
	url = [email protected]:example/shop.git
	fetch = +refs/heads/*:refs/remotes/origin/*
[alias]
	lg = log --oneline --graph --decorate
Output
[user]
  name = Aisha Tan
  email = [email protected]

[remote "origin"]
  url = [email protected]:example/shop.git
  fetch = +refs/heads/*:refs/remotes/origin/*

[alias]
  lg = log --oneline --graph --decorate
Open this example in the tool

MySQL my.cnf with bare flags

Flags without a value, inline comments and the !includedir line are all preserved with compact key=value spacing.

Input
[mysqld]
skip-name-resolve
max_connections=200 ; raised for the import job
innodb_buffer_pool_size=1G
!includedir /etc/mysql/conf.d/
Output
[mysqld]
skip-name-resolve
max_connections=200 ; raised for the import job
innodb_buffer_pool_size=1G
!includedir /etc/mysql/conf.d/
Open this example in the tool

Common errors and how to fix them

ErrorCauseFix
Unclosed '[' in section header on line 1A section header is missing its closing bracket, often after a copy that cut the line short.Add the missing ‘]’ so the header reads like [database].
Line 4 is not a section, key or commentThe line contains spaces but no = or : separator, so it is neither a key nor a bare flag. A comment written with // instead of ; or # also triggers this.Write it as key = value, or start the line with ‘;’ or ‘#’ if it is a comment.
Duplicate key 'memory_limit' (first defined on line 3)The same key appears twice in one section. This is a warning, not an error, because some dialects allow it.Delete the stale line. Most parsers keep the last value, but Python configparser rejects the file.
Unexpected text 'port=5432' after section header on line 2A key was written on the same line as its section header.Move the key to its own line below the header.

Frequently asked questions

Does the INI formatter remove or reorder comments?

No. Every comment line is kept, including ones starting with # in files that normally use ;. When you sort keys, comments stay next to the keys they were written above.

Can it format .gitconfig, .editorconfig and setup.cfg files?

Yes. They are all INI dialects. Indented keys in git config stay indented, and configparser continuation lines in setup.cfg stay attached to their key.

Why does it warn about duplicate keys instead of failing?

Because whether a repeated key is valid depends on the program reading it. PHP keeps the last value, git treats repeats as a list, and configparser refuses the file, so the formatter points it out and lets you decide.

Are values with spaces or special characters changed?

No. The formatter only adjusts whitespace around separators, blank lines between sections and indentation. Values, quotes and escape sequences are written back exactly as they were.

Is it safe to paste a my.cnf or php.ini that contains passwords?

Yes. Parsing and formatting happen in your browser and nothing you paste is sent to a server. Even so, rotate any credential that ends up in a shared link or screenshot.

Related tools