Convert php.ini Configuration to JSON

Convert PHP's php.ini configuration file to JSON format. Covers PHP-specific values like memory_limit, error_reporting, and extension directives.

Common Files

Detailed Explanation

php.ini to JSON

PHP's php.ini is one of the most widely used INI-format configuration files. It controls PHP's runtime behavior including memory limits, error handling, file uploads, session management, and extension loading.

Example php.ini

[PHP]
engine = On
short_open_tag = Off
precision = 14
output_buffering = 4096
max_execution_time = 30
max_input_time = 60
memory_limit = 256M
error_reporting = E_ALL & ~E_DEPRECATED
display_errors = Off
log_errors = On
error_log = /var/log/php_errors.log
upload_max_filesize = 50M
post_max_size = 55M

[Date]
date.timezone = America/New_York

[Session]
session.save_handler = files
session.gc_maxlifetime = 1440
session.cookie_secure = 1
session.cookie_httponly = 1

Generated JSON

{
  "PHP": {
    "engine": true,
    "short_open_tag": false,
    "precision": 14,
    "output_buffering": 4096,
    "max_execution_time": 30,
    "max_input_time": 60,
    "memory_limit": "256M",
    "error_reporting": "E_ALL & ~E_DEPRECATED",
    "display_errors": false,
    "log_errors": true,
    "error_log": "/var/log/php_errors.log",
    "upload_max_filesize": "50M",
    "post_max_size": "55M"
  },
  "Date": {
    "date.timezone": "America/New_York"
  },
  "Session": {
    "session.save_handler": "files",
    "session.gc_maxlifetime": 1440,
    "session.cookie_secure": 1,
    "session.cookie_httponly": 1
  }
}

PHP-Specific Considerations

  • On/Off values: PHP uses On and Off (case-insensitive) as boolean equivalents, which are coerced to true/false
  • Memory notation: Values like 256M, 50M remain as strings because they contain unit suffixes
  • Dot-prefixed keys: Keys like session.cookie_secure are NOT interpreted as nested sections — they are treated as literal key names within their section
  • PHP constants: Values like E_ALL & ~E_DEPRECATED remain as strings since they are PHP-specific expressions
  • Disabled directives: Some php.ini files use commented-out lines with ; to show available but disabled options

Use Case

Auditing PHP configuration across multiple servers by converting each server's php.ini to JSON, then using tools like jq or a script to diff the configurations and identify discrepancies in security or performance settings.

Try It — INI \u2194 JSON Converter

Open full tool