Skip to content

Convert INI to XML

Convert INI settings into usable XML while checking syntax, encoding, and target schema limits.

Convert INI files online

We don’t have a dedicated online converter for INI to XML yet, but you can convert INI files online to these formats:

Want to convert INI to XML?

Let us know. We pick the conversions to add next by how many people ask for them.

How to convert ini to xml file

A program, device utility, or configuration-management system may require XML when the original settings are stored in INI format. Converting the file allows the settings to be imported, validated against an XML schema, or exchanged with software that cannot read INI.

What the INI format is

INI is a plain-text configuration format built from sections and key-value pairs, such as timeout=30 under [network]. It is common in Windows applications, legacy desktop software, games, installers, development tools, and vendor-specific device utilities.

INI has no universal specification. Programs differ in their comment characters, delimiters, quoting, interpolation, duplicate-key behavior, case sensitivity, multiline values, and support for arrays or nested data. A file that is valid for one application may not be valid for another.

What the XML format is

XML represents data with nested elements, attributes, text values, closing tags, and defined escaping rules. It can be accompanied by namespaces and an external XSD schema for structure and data-type validation; XML does not validate itself automatically.

XML suits applications that require a defined hierarchy, namespaces, schema validation, or standardized data exchange. It is usually more verbose than INI, so conversion normally increases file size rather than reducing it.

How to convert INI to XML

For a local conversion, Python's standard-library configparser and xml.etree.ElementTree provide a repeatable option without uploading credentials, API keys, hostnames, or device settings. This script creates a general XML representation; it does not guess the XML schema required by a particular application.

  1. Install Python 3 from python.org if it is not already available.
  2. Save the following code as ini_to_xml.py:
import configparser
import sys
import xml.etree.ElementTree as ET

source, target = sys.argv[1:3]
config = configparser.ConfigParser(
    interpolation=None,
    strict=False,
    empty_lines_in_values=False
)
config.optionxform = str

with open(source, encoding="utf-8") as file:
    config.read_file(file)

root = ET.Element("configuration")

def add_section(parent, name, values):
    section = ET.SubElement(parent, "section", {"name": name})
    for key, value in values.items():
        entry = ET.SubElement(section, "entry", {"name": key})
        entry.text = value

if config.defaults():
    add_section(root, "DEFAULT", config.defaults())

for section_name in config.sections():
    # _sections contains values written in this section, excluding DEFAULT values.
    values = {
        key: value
        for key, value in config._sections[section_name].items()
        if key != "__name__"
    }
    add_section(root, section_name, values)

ET.indent(root, space="  ")
ET.ElementTree(root).write(target, encoding="utf-8", xml_declaration=True)
  1. Run it from a terminal:
python ini_to_xml.py settings.ini settings.xml

For an input containing [network] and timeout=30, the output includes:

<configuration>
  <section name="network">
    <entry name="timeout">30</entry>
  </section>
</configuration>

The generic structure uses section and key names as attribute values, so names that are not valid XML element names can still be represented. If the receiving application requires a specific root element, child elements, attributes, namespace, or schema, change the script to generate that structure instead of importing this output unchanged.

Desktop and online options

For occasional manual conversion, use Notepad++ or another plain-text editor to map each INI section and key into the XML structure required by the target program. Oxygen XML Editor and similar desktop XML editors can format, edit, and validate the resulting XML, but they do not provide a universal INI import because INI has no consistent data model.

An online converter is suitable only for a simple, non-sensitive file. Use a reputable service only when its current format list explicitly accepts INI input and produces XML output; generic document converters may reject INI or treat it as unstructured text. Do not upload passwords, private keys, API credentials, proprietary settings, or device configuration. Downloaded XML should be checked locally before use.

Quality and compatibility limits

The script preserves section names and parsed values, but it does not preserve comments, original spacing, formatting, or application-specific syntax. It also does not reproduce the behavior of interpolation, environment-variable expansion, conditional settings, or custom array and nested-value conventions.

strict=False allows duplicate keys during parsing, but only the last value is retained. Remove that option when duplicate keys should cause an error. interpolation=None copies percent sequences literally instead of treating them as references. The default parser also expects supported delimiters and rejects some INI dialects, including bare keys unless allow_no_value=True is configured.

The example reads UTF-8 and writes UTF-8 with an XML declaration. Identify the original program's character encoding before conversion; older Windows software may use a code page such as Windows-1252. Invalid XML control characters cannot be written, and values with XML-sensitive characters are escaped by ElementTree.

Validate the result with the target application's importer or its XSD, then test the settings in a non-production environment. A syntactically valid XML file can still be incompatible with the receiving program's required names, types, defaults, ordering, or namespace.

INI vs XML: format comparison

How the INI and XML formats compare on the properties that matter most for this conversion.

Comparison of the INI and XML file formats
Property .INI INI file .XML Extensible Markup Language
Open standard — Yes
Compression Uncompressed Uncompressed
Typical file size Very small Small
Opens in a web browser No Yes, natively
Further editing Easy Easy
Metadata support Basic Basic
Plain-text readable Yes Yes
Best used for Data exchange Data exchange
Introduced — 1998
Developer — W3C
MIME type — application/xml

Information about file extensions and file types is provided by File-Extensions.org

Already downloaded

This file has already been downloaded. For your privacy it was deleted from our server right after the download, so it cannot be downloaded again. To get it once more, convert the file again.