CONFIG File Documentation


Summary

A Configuration File stores settings that a program reads to know how to run. The .config extension is generic and reused by many applications, so what sits inside depends on the program that wrote it. The dominant real-world case is Microsoft .NET, where App.config and Web.config are XML files (MIME text/xml).

Edit one in a code editor, never a word processor, and back up the original first: a broken tag can stop a .NET app from starting.

Technical details

Full nameConfiguration File
File extension.config
MIME typetext/xml for the .NET case; otherwise text/plain
Format typeUsually plain-text settings; most often XML
Dominant variantMicrosoft .NET App.config / Web.config (XML)
DeveloperN/A (generic extension); Microsoft for the .NET case
Introduced.NET App.config / Web.config since .NET Framework 1.0 (2002)
.NET root element<configuration>
Common formsXML, INI key=value, YAML
Magic numberNone (application-defined); <?xml in the .NET case
Open standardNo
Related extensions.cfg, .ini, .conf, .xml, .json, .yaml
Edit withText or code editor, not a word processor
Structure at a glance
<?xml version="1.0"?>

The common Microsoft .NET variant is XML: an <?xml> prolog and a <configuration> root holding <appSettings> and <connectionStrings>. Other .config files are INI-style key=value text or YAML; a few are proprietary binary. There is no universal signature — identify by the program.

What is a .config file?

A .config file holds settings that a program reads so it knows how to behave. The name is short for "configuration". Unlike a format such as PNG or PDF, .config is generic: dozens of unrelated applications use it, and there is no single layout they all share. Its siblings .cfg, .ini, and .conf mean the same thing in practice, and the choice between them is mostly a matter of convention.

Because the extension is shared, you cannot tell what is inside from the name alone. There is no universal magic number to look for. What a .config file contains is decided by whatever wrote it: it might be XML, plain key=value lines, YAML, or a proprietary binary blob. To understand a stray one, you have to work out which program owns it.

The Microsoft .NET case

The most common .config file you will meet is a Microsoft .NET one. These are XML documents, and they arrived with .NET Framework 1.0 in 2002. Two names dominate. A desktop application uses App.config during development, and it ships next to the compiled binary renamed to match the executable, so MyApp.exe is paired with MyApp.exe.config. A web application uses Web.config for ASP.NET settings. In both cases the runtime reads the file when the application starts.

Every .NET config is XML built around a <configuration> root element (see XML). A small App.config looks like this:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <appSettings>
    <add key="LogLevel" value="Warning" />
    <add key="MaxRetries" value="3" />
  </appSettings>
  <connectionStrings>
    <add name="MainDb"
         connectionString="Server=db01;Database=Orders;Integrated Security=true" />
  </connectionStrings>
</configuration>

Inside a .NET config

A few sections do most of the work. <appSettings> is a list of key/value pairs the program reads at runtime, useful for flags and tuning values like a log level or a feature toggle. <connectionStrings> stores the details an app needs to reach a database: server name, database, and credentials. There are also runtime and assembly-binding sections that tell .NET which versions of dependent libraries to load.

Editing one of these changes real behavior. Point MainDb at a different server and the app talks to a different database on the next start. Flip a flag in <appSettings> and a code path switches on or off. One caution: connection strings and similar entries can hold passwords, API keys, and other secrets, so a Web.config is confidential and should not be shared or committed to a public repository.

The non-.NET forms

Plenty of .config files have nothing to do with .NET. Many are plain text in the key=value style, often with # or ; starting a comment line. This is the same idea as an INI file or a CFG file, its close siblings. A typical one reads:

# database connection
host = 127.0.0.1
port = 5432
user = appuser
# leave blank to use defaults
timeout =

Others use YAML for nested settings. You will also find files literally named config with no extension at all: the GNU build tooling writes one when you run ./configure, and many frameworks keep a file by that name. A minority of .config files are proprietary binary and look like gibberish in a text editor; those can only be changed through the program that made them.

Working out which program owns a stray config

When you find a .config file and do not know what created it, its folder is the first clue: it usually sits beside the program or project it belongs to. To learn whether it is text or binary, open it in a code editor and look at the start. A <?xml prolog followed by <configuration> means a .NET XML config. Readable key=value lines mean an INI-style text config you can edit directly. If the content is unreadable symbols, it is a proprietary binary format, and you should leave it to the owning program rather than hand-edit it.

FAQ

Why did editing my Web.config stop the app starting? Almost always because the XML is no longer valid: a missing closing tag, a mismatched element, or a character the parser rejects. .NET reads the file at startup, and if it cannot parse it, the app fails immediately. Restore your backup, then reapply the change carefully in an XML-aware editor.

Is .config the same as .cfg or .ini? In spirit, yes. All three are configuration files, and the plain-text ones follow the same key=value idea. The difference is that .config is strongly associated with Microsoft .NET XML files, whereas .cfg and .ini are more often simple text. The extension does not force a format, so always check the contents.

References