.INI Initialization File
.ini

Initialization File

An INI file is a plain text configuration file organized into named sections with key-value pairs. Introduced with Windows 1.0 in 1981, it remains ubiquitous in php.ini, .gitconfig, and game settings. This is a reference page only.

بنية الصيغة
Header magic bytes
Sections code · data
Plain TextKey-ValueSectionsWindows Native1981
بواسطة FileDex
غير قابل للتحويل

Configuration file. Format conversion between config formats requires semantic mapping.

أسئلة شائعة

What is an INI file?

An INI file is a plain text configuration file organized into named sections (e.g., [Database]) with key-value pairs (host=localhost). It was the primary configuration format for Windows applications before the Windows Registry. Today it is still widely used for php.ini, .gitconfig, and game settings.

How do I open an INI file?

Open it with any text editor: Notepad on Windows, TextEdit on macOS, or VS Code on any platform. INI files are plain text. On macOS Terminal, use 'open -e file.ini' for TextEdit or 'code file.ini' for VS Code.

Can INI files store arrays or lists?

The base INI format does not support arrays. Some parsers extend the format with workarounds: repeated keys (item[]=value1, item[]=value2), numbered keys (item1=a, item2=b), or comma-separated values. If you need arrays, consider TOML or JSON for new projects.

What is the difference between INI and TOML?

TOML is a modern INI replacement with a formal specification, typed values (integers, booleans, dates), arrays, and nested tables. INI treats all values as strings and has no standard. For new projects, TOML is strictly better; for legacy compatibility, INI is necessary.

Is it safe to commit INI files to version control?

It depends on the contents. INI files with non-sensitive settings (feature flags, UI preferences) are safe. INI files containing passwords, API keys, or database credentials must never be committed. Add *.ini to .gitignore if your INI files might contain secrets.

How do I open an INI file on Mac?

INI files are plain text and can be opened with any text editor on macOS. Double-click the file and it should open in TextEdit. For better syntax highlighting, open it with VS Code (free) or BBEdit. From the Terminal: `open -e file.ini` forces TextEdit, or `code file.ini` opens VS Code. If a `.ini` file has no associated application, right-click it, choose 'Open With', and select TextEdit.

What is php.ini and can I edit it?

php.ini is the configuration file for the PHP runtime — it controls memory limits (`memory_limit = 256M`), file upload sizes (`upload_max_filesize = 10M`), error reporting, loaded extensions, and dozens of other settings. You can edit it with any text editor, but changes only take effect after restarting PHP-FPM or Apache. Find its location with `php --ini` from the command line. On shared hosting, you may have a local php.ini or use `ini_set()` in code instead.

ما يميز .INI

What is an INI file?

INI (Initialization) files are simple text-based configuration files organized into sections with key-value pairs. They were the primary configuration format for Windows applications before the registry and XML/JSON configs became standard. The format was introduced with early versions of Windows and remains widely used today because of its human-readable simplicity.

اكتشف التفاصيل التقنية

An INI file groups related settings under named sections enclosed in square brackets. Each setting is expressed as a key=value pair on its own line. Comments begin with a semicolon (;) or hash (#) and are ignored by parsers.

How to open INI files

  • Notepad (Windows) — Built-in, no installation required
  • Any text editor — Universal support across all platforms
  • VS Code (Windows, macOS, Linux) — Syntax highlighting with extensions
  • Notepad++ (Windows) — Enhanced editing with syntax coloring
  • Vim / Nano (Linux/macOS) — Terminal-based editing

Technical specifications

Property Value
Format Plain text
Structure [Section] / key=value
Comments ; semicolon or # hash
Encoding ASCII, UTF-8, UTF-16
Nesting Not supported (flat structure)
Line endings LF or CRLF
File size Typically < 100 KB

Common use cases

  • Application settings: Desktop application configuration (e.g., app.ini, config.ini)
  • PHP configuration: The php.ini file controls PHP runtime behavior, memory limits, and extensions
  • Git configuration: .gitconfig uses INI syntax for user identity, aliases, and remote URLs
  • Game settings: Many games store resolution, keybindings, and graphics options in INI files
  • Wine emulator: Wine uses wine.ini to configure Windows application compatibility on Linux

INI file structure example

[Database]
host=localhost
port=5432
name=myapp_db

[Server]
host=0.0.0.0
port=8080
debug=false

; API keys — never commit to source control
[Auth]
secret_key=replace_with_real_key

Security considerations

INI files are plain text and should never contain passwords, API keys, or connection strings that are committed to version control. Use environment variables or encrypted secrets managers for sensitive values. If an INI file containing secrets is accidentally committed, rotate the credentials immediately and use git filter-repo to purge the file from history.

Developer tools and parsing libraries

Most programming languages have built-in or popular libraries for reading INI files:

  • Python: configparser (standard library)
  • PHP: parse_ini_file() (built-in function)
  • C#/.NET: IniFile class or ConfigurationManager
  • Node.js: ini npm package
  • Java: java.util.Properties (similar key=value syntax)

Limitations and alternatives

INI has no support for nested structures, typed values (everything is a string), or arrays. Modern applications often prefer JSON (.json), YAML (.yaml), or TOML (.toml) for complex configuration needs. However, INI remains the best choice when configuration must be edited by non-technical end users — it requires no knowledge of brackets, quotes, or indentation rules.

المرجع التقني

نوع MIME
text/plain
المطوّر
Microsoft
سنة التقديم
1985
معيار مفتوح
نعم

البنية الثنائية

INI files are plain text with no binary structure. The file is divided into named sections denoted by square brackets (e.g., [Database]). Within each section, settings are expressed as key=value pairs, one per line. Lines beginning with ; (semicolon) or # (hash) are comments. There are no headers, magic bytes, or binary framing. Encoding is typically ASCII, UTF-8, or UTF-16. The format has no formal specification — behavior around whitespace trimming, quoting, duplicate keys, multi-line values, and escape sequences varies across parser implementations.

1981WIN.INI and SYSTEM.INI introduced with Windows 1.0 as the primary configuration mechanism1991Windows 3.1 popularizes INI files; GetPrivateProfileString() API widely adopted by third-party apps1993PHP adopts INI syntax for php.ini runtime configuration1994Windows 95 introduces the Windows Registry as the intended replacement for INI files2001Git adopts INI-style syntax for .gitconfig, keeping the format relevant in Unix/open-source ecosystems2013TOML created as a formal, typed successor to INI with a proper specification
Read an INI file with Python configparser أخرى
import configparser

config = configparser.ConfigParser()
config.read('app.ini')

# Access values
host = config['Database']['host']
port = config.getint('Database', 'port')  # auto-convert to int
debug = config.getboolean('Server', 'debug')  # auto-convert to bool

print(f"Connecting to {host}:{port}")

Parse an INI file in Python using the standard library configparser module

Write an INI file with Python configparser أخرى
import configparser

config = configparser.ConfigParser()
config['Database'] = {
    'host': 'localhost',
    'port': '5432',
    'name': 'myapp_db',
}
config['Server'] = {
    'host': '0.0.0.0',
    'port': '8080',
    'debug': 'false',
}

with open('app.ini', 'w') as f:
    config.write(f)

Create and write an INI file in Python using configparser

Parse INI file in PHP أخرى
<?php
// Parse an INI file into a multidimensional array
$config = parse_ini_file('app.ini', process_sections: true);

echo $config['Database']['host'];   // localhost
echo $config['Server']['port'];     // 8080

// Parse INI string directly
$ini_string = "[Auth]\ntoken=abc123\n";
$parsed = parse_ini_string($ini_string, process_sections: true);

Read INI files in PHP using the built-in parse_ini_file() function

Read git INI config from command line أخرى
git config --list --show-origin

Show all git configuration values and which INI file each comes from

INI JSON export lossy Converting INI to JSON enables use with modern web APIs, JavaScript tooling, and configuration management systems that expect structured JSON input.
INI YAML export lossy YAML preserves readability while adding type support and nesting. Useful for migrating legacy INI configs to modern DevOps tooling (Ansible, Docker Compose).
INI TOML export lossy TOML is the natural successor to INI with a formal spec, typed values, and nested tables. Migration preserves the section/key-value structure while adding type safety.
منخفض

نقاط الضعف

  • Secrets stored in INI files committed to version control
  • World-readable INI files on shared servers expose database passwords and API keys
  • Secrets stored in INI files committed to version control
  • World-readable INI files on shared servers

الحماية: FileDex does not open, execute, or parse these files. Reference page only.

Notepad أداة
Built-in Windows text editor for basic INI editing
VS Code أداة
Free editor with INI syntax highlighting via community extensions
Python configparser مكتبة
Standard library module for reading and writing INI-style configuration files
PHP parse_ini_file() مكتبة
Built-in PHP function that reads INI files and returns an associative array
.gitconfig مواصفات
Git configuration file using INI syntax for user identity, aliases, and remotes