Convert INI to XML

Converting INI to XML turns each bracketed section into an element and every key beneath it into a child of that element. A file with one section gets that section as its root tag; a file with several is wrapped in a root element, because XML permits exactly one. The conversion runs in your browser and the file never leaves it.

  • Where it runs In your browser. The file is never uploaded.
  • Lossless Nothing is discarded. The XML holds exactly what the INI held.
  • File size limit Up to 100 MB per file, free, without an account.

Up to 100 files at once. Mixed formats are fine.

What an INI file looks like once it is XML

The mapping is direct enough to predict. A section header becomes an element, each key under it becomes a child element, and the value becomes that element text. An INI file holding [db] with host and port under it comes out as a db element containing a host element and a port element, indented two spaces per level.

That predictability is the reason this pair is worth a tool rather than a script. There is no ambiguity to resolve, because an INI file offers a converter almost nothing to interpret: one level of grouping, one key, one value per line. Everything interesting happens at the edges, and the rest of this page is those edges.

Whether your INI file gets a root element of its own

XML requires exactly one outermost element and an INI file has no concept of one. The converter resolves that by looking at what it read: if the file contained a single section and nothing else, that section becomes the root, so a one-section file named [settings] produces a document whose root tag is settings. Anything else — two sections, or keys written above the first section header — is wrapped in a generic root element.

This is worth knowing before you write an XSD or an XPath against the result. Adding a second section to the source INI file silently changes the root element of the output from settings to root, and every path expression written against the first version stops matching. If the document shape matters downstream, decide on the wrapper yourself and keep it stable rather than letting the section count decide it.

Every INI value arrives as element text, typed by guesswork

INI has no type system at all: everything to the right of the equals sign is characters. The reader guesses anyway, turning true and false into booleans and anything that parses as a number into a number, and the XML writer then prints whatever it got back out as text. For most keys the round trip is invisible.

For some it is not. A value written 007 is read as the number 7 and written back as 7. A version key written 1.0 becomes 1. A hexadecimal mask written 0x1F comes out as 31, and a Unix file mode written 0755 comes out as 755, which is a different mode. Anything with a unit attached survives intact, so 128M stays 128M, and so do dotted addresses like 127.0.0.1 and clock times like 08:00, because neither parses as a single number.

Keys that are not legal XML element names

XML is far stricter about names than INI is. An INI key can contain spaces, slashes, colons and brackets; an element name can contain letters, digits, underscores, hyphens, dots and little else, and it may not begin with a digit. The writer therefore substitutes an underscore for every character it cannot use, and prefixes an underscore to any name that starts with something other than a letter or an underscore.

The substitution is not reversible, so two keys that differ only in punctuation collide into the same element name — "log level" and "log-level" do not, since the hyphen is legal, but "log level" and "log/level" both become log_level. If your INI file has keys like that, rename them in the source before converting rather than trying to work out afterwards which element came from which line.

Dotted section names, and why [tool.black] stays one tag

A section header written [database.pool] looks like it should nest, and in TOML it would. Here it does not: the reader takes everything between the brackets as one section name, so the output holds a single element named database.pool with the keys inside it. Dots are legal in XML element names, so the document is valid; it is simply flat where you may have expected depth.

If the target schema wants real nesting, that structure has to be created rather than converted. The honest sequence is to convert first, then reshape the resulting XML with XSLT or by hand, because a converter that guessed at nesting from punctuation would guess wrong on every INI file where a dot is part of a name rather than a separator — and PHP configuration files, where keys like date.timezone are everywhere, are exactly that case.

What a repeated INI section header quietly costs you

INI has no standard, only conventions, and one of the places implementations disagree is what a repeated section header means. Some merge the two blocks. This reader does not: it creates a fresh empty section each time it sees a header, so a file with [logging] appearing twice keeps only the keys from the second occurrence and loses the first block entirely, without an error.

Repeated headers are rare in files written by hand and common in files assembled by concatenation — a base config with an environment overlay appended, which is a real deployment pattern. Search the source for duplicate headers before converting, because the failure is silent and the output is a perfectly well-formed XML document that is simply missing settings.

The comments in the INI file are the part you lose

Both formats support comments. INI marks them with a semicolon or a hash, XML with an angle-bracket block, and this conversion carries none of them across: comment lines are skipped during reading and never reappear. The registry records both formats as comment-capable, which makes the loss an artefact of the pipeline rather than a limitation of the target.

On a configuration file that matters more than it sounds. The line above a timeout explaining that it was raised to 90 seconds because of one slow report is usually the only record of that decision anywhere. Copy the commented original into version control before converting, and reattach the explanations to the XML afterwards; nothing in an automated conversion of this kind can do it for you.

What XML gives you that the INI file never could

The reason to make this move is almost never the syntax. XML 1.0 has been a W3C recommendation since 1998, and around it sits the machinery INI never had: XSD schemas that reject a config with a misspelled key before the application starts, XPath for pulling one value out of a large document, XSLT for reshaping it, and XML digital signatures for asserting that a config file has not been altered.

None of that arrives with the conversion. The output is a well-formed document with no schema attached and no namespace declared, and writing the schema is the actual work — the conversion just gets you a starting document to write it against. If you do not intend to validate, sign or transform the result, the migration is buying you verbosity and nothing else.

When to leave the INI file where it is

If the application reading the file is the one that wrote it, and nothing downstream needs a schema, converting is a cost with no return. An INI file is editable by anyone who can open Notepad, and that is a genuine operational property when the person changing a setting at two in the morning is not a developer.

The conversion is also the wrong tool if what you actually need is two or three values out of the file rather than the whole thing. Read them out directly. This converter is for the case where the INI file is the config and the config is moving, not for extracting a fragment.

How to convert INI to XML

  1. Drop your INI file onto this page, or click to choose one.
  2. It is read and rewritten as XML in your browser.
  3. Download the XML document.

INI against XML: a flat list meeting a tree

INI compared with XML
INIXML
Full nameINI ConfigurationExtensible Markup Language
File extension.ini, .cfg, .conf.xml
Media typetext/plainapplication/xml
First published19851998
Published byW3C
SpecificationXML 1.0
LicensingOpen standardOpen standard
Standing todayLegacy, still read everywhereCurrent
Opens in a browserNo browserEvery browser
Considered insteadTOML, YAMLJSON, YAML

What survives

Comments carry across. Both INI and XML have a comment syntax, so notes left for whoever maintains the file next are not silently thrown away.

Opening the result

XML opens in every current browser. INI has narrower browser support than that. If the file is going onto a web page or into a form, that is usually the whole reason for the conversion.

INI dates from 1985 and is largely superseded. XML is what current software writes, so the conversion is as much about staying readable as about the file itself.

Visual Studio Code reads both INI and XML, so there is a way to check the result against the original without a second tool.

What each format is for

The two are aimed at different work: INI at editing, XML at moving data between programs. That is worth weighing before converting, because the reason one exists is usually the reason the other is awkward.

XML comes from W3C and dates from 1998, specified as XML 1.0. Visual Studio Code and oXygen XML Editor all read it.

INI to XML: what people ask before migrating a config

Are my INI files uploaded anywhere?

No. This conversion runs entirely inside your browser, so the file never leaves your device. You can confirm it yourself: open the network tab of your browser's developer tools and convert something. You will see the page load, plus the analytics and advertising the site is paid for with — and nothing carrying your file.

What becomes the root element?

If the INI file has exactly one section, that section name becomes the root element. If it has two or more sections, or any keys sitting above the first section header, the whole document is wrapped in a root element instead, because XML allows only one outermost tag.

Does the output include an XML declaration?

No. The file starts with the first element, not with a version and encoding line. The output is UTF-8, so most parsers are correct without it, but if your validator insists on one, add it by hand as the first line.

What happens to a key with a space in it?

Characters that are not letters, digits, underscore, dot or hyphen are replaced with an underscore, because they are not legal in an XML element name. A key written "log level" becomes log_level. A key starting with a digit gets an underscore in front of it.

Are my comments carried over?

No. Lines starting with a semicolon or a hash are skipped while reading, and nothing writes them back as XML comments. Both formats support comments and this conversion still loses all of them, which is usually the most valuable text in an old config file.

Can nested sections like [database.pool] be represented?

They come across as a single element named database.pool, not as a pool element inside a database element. The reader treats the whole bracketed string as one section name, and dots are legal in XML element names, so the odd-looking tag is valid but flat.

Does the conversion run on your servers?

No. Both the reader and the writer are plain JavaScript running in this page, so the file stays on your machine. Files up to 100 MB are accepted on the free tier, which no realistic INI file approaches.

More about these formats