INI Cheatsheet - INI Configuration Reference
INI is simple, but parsers differ: the comment character, quote handling, nesting support and variable interpolation all vary by implementation. This reference organizes 8 groups of basic syntax and data types, plus four real-world scenarios — Windows, php.ini, Git config and Python configparser — and a dedicated parsing-caveats group on cross-parser differences. After reading you can judge quickly whether a given INI block is safe in the target parser and avoid common traps like BOM, duplicate keys and comment-character issues.
Basic Syntax 7
; this is a comment# this is also a comment[section]key = valuekey = "quoted value"key =; key = commented outData Types 7
string = hellointeger = 42float = 3.14boolean = truearray = value1,value2,value3hex = 0xFFpercent = 50%Common Applications 5
[database]\nhost = localhost\nport = 3306[server]\nlisten = 8080\nmax_connections = 100[logging]\nlevel = info\nfile = /var/log/app.log[user]\nname = Alice\nemail = alice@example.com[cache]\ndriver = redis\nttl = 3600PHP php.ini Example 9
[PHP]\nmemory_limit = 256Mupload_max_filesize = 20Mpost_max_size = 25Mmax_execution_time = 30display_errors = Onerror_reporting = E_ALLdate.timezone = Asia/Shanghaisession.save_path = /tmpsession.gc_maxlifetime = 1440Git Config Example 7
[user]\nname = Your Name\nemail = you@example.com[core]\neditor = vim\nautocrlf = input[alias]\nco = checkout\nbr = branch\nlg = log --oneline --graph[remote "origin"]\nurl = https://github.com/user/repo.git[diff]\ntool = vimdiff[merge]\ntool = vimdiff\nconflictstyle = diff3[pull]\nrebase = trueWindows INI Example 5
path = C:\\Program Files\\App[Environment]\nPATH = %PATH%;C:\\bintemp = %TEMP%\\appapp_dir = ${APPDIR}key = value ; trailing commentPython configparser 6
config.read("config.ini")config.write(open("config.ini", "w"))config["section"]["key"]config["section"]["key"] = "value"config["DEFAULT"]["key"]config.getint("section", "port")Parsing Caveats 6
; vs #key="value" vs key = value[[nested]]BOM: \xEF\xBB\xBFkey = ; not a commentduplicate keysTips
- INI syntax is simple but has no nesting; use YAML or TOML for complex configs.
- Comment support varies by parser; semicolon (;) is the most portable.
- Spaces around the = are optional; parsers strip them automatically.
- Escape backslashes in Windows paths; prefer forward slashes or double backslashes.
- Python configparser has no default var interpolation; use ExtendedInterpolation.
- Use UTF-8 without BOM for INI files to avoid first-section parse failures.
Official References
Each command links to its official documentation below, so you can verify the latest usage and read deeper.
Maintained by LaoHand
Publicly updated on Jul 21, 2026, continuously proofread against official docs.
Contact Us
Wrong command or description? Send us corrections, business inquiries or product feedback by email.
Contact Us