Handling Valueless Keys in INI Files

Learn how INI keys without values (no equals sign) are handled during conversion, with options to treat them as boolean true or empty strings.

Advanced

Detailed Explanation

Valueless Keys

Some INI-style configuration files include keys without an equals sign or value. These "bare keys" or "flags" are common in MySQL's my.cnf, pip.conf, and other tools where a key's mere presence indicates activation.

Example INI

[mysqldump]
quick
single-transaction
routines
triggers
max_allowed_packet=64M

[pip]
trusted-host
no-cache-dir
prefer-binary

[features]
experimental
beta-features
stable=true

JSON with "Valueless as true"

{
  "mysqldump": {
    "quick": true,
    "single-transaction": true,
    "routines": true,
    "triggers": true,
    "max_allowed_packet": "64M"
  },
  "pip": {
    "trusted-host": true,
    "no-cache-dir": true,
    "prefer-binary": true
  },
  "features": {
    "experimental": true,
    "beta-features": true,
    "stable": true
  }
}

JSON with "Valueless as empty string"

{
  "mysqldump": {
    "quick": "",
    "single-transaction": "",
    "routines": "",
    "triggers": "",
    "max_allowed_packet": "64M"
  },
  "pip": {
    "trusted-host": "",
    "no-cache-dir": "",
    "prefer-binary": ""
  },
  "features": {
    "experimental": "",
    "beta-features": "",
    "stable": true
  }
}

Choosing the Right Strategy

Strategy Best for Behavior
As true MySQL, flags, boolean options Key presence = enabled
As empty string Placeholder configs, templates Key exists but has no value

Round-Trip Behavior

When converting back to INI:

  • true values from valueless keys can be written as bare keys (no =)
  • Empty string values are written as key= (with equals but no value)

This allows you to choose the semantic that best matches your configuration file's conventions.

Use Case

Parsing MySQL my.cnf or pip configuration files where certain directives are boolean flags activated by their mere presence, and converting them to JSON for use in infrastructure-as-code tools that need explicit boolean values.

Try It — INI \u2194 JSON Converter

Open full tool