跳到主要内容
uencoder

INI Format Reference

INI 配置 file 格式化: sections, 关键, values, comments, 和 dialect variations.

Core Syntax

The INI format is an informal configuration format consisting of sections in square brackets and key-value pairs separated by equals signs or colons. Comments begin with semicolons or hash signs and are ignored by parsers. The format predates any formal standard, so every parser implements a slightly different dialect. Despite this, INI remains popular for simple configuration due to its minimal syntax.

section
Bracketed header grouping keys
[database]
key=value
Assignment within a section
port = 5432
comment
Line starting with ; or #
; a comment
default section
Keys before any section header
root-only keys

Dialect Differences

Some parsers support duplicate keys by keeping the last or merging values, while others reject them. Multiline values are handled differently: some use continuation backslashes, others allow raw newlines. Quoting of values varies, with some dialects stripping quotes and others treating them literally. Interpolation of variables referencing other keys is a common non-standard extension. These differences make cross-tool portability unreliable.

Limitations

INI lacks a standard type system, so all values are strings until the application interprets them. Nested structures are not supported natively, though dotted keys are sometimes used as a convention. Binary and large data do not fit well in the line-oriented format. For complex configuration, TOML or YAML are better choices, but INI remains useful for flat, simple settings where minimalism is valued.

相关工具

参考链接