Magento is a fully customizable eCommerce platform that enables developers to create custom modules and configure the settings of a website from the admin only to suit a store’s specific requirements. One of the key files in module development is the system.xml file. If you’ve been working with Magento 2, you’ve likely encountered this configuration file and may be curious about the purpose of the system.xml file and how to utilize it.
This blog post will give you a detailed overview of what a system.xml file is, how you can create the system.xml file, and when this file is required.
What is system.xml in Magento 2?
The system.xml file is responsible for managing the system configuration settings of the Magento admin website. The system.xml file is generally located at etc/adminhtml/ in the magento 2 module directory. The system.xml file’s settings can be located at STORES > Configuration in Magento 2 admin.
Before discussing the system.xml file, you should first know how the system.xml file looks and its structure. Below is a sample of the Magento 2 system.xml file.
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
<tab id="module_tab_id" translate="label" sortOrder="51" class="module-tab-calssname">
<label>Module Tab Name</label>
</tab>
<section id="module_section_id" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<class>separator-top</class>
<label>Module Section Name</label>
<tab>module_tab_id</tab>
<resource>Your_Module::config</resource>
<group id="module_group_id" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Module Group Name</label>
<field id="module_field_id" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Module Field Name</label>
</field>
</group>
</section>
</system>
</config>
The system.xml file contains different tags and child tags like tab, section, group, and field. Let’s describe each in detail.
TAB: The <tab> tag creates the top-level main tab at STORES > Configurations. For example, GENERAL, CATALOG, CUSTOMERS, SALES, etc., are default tabs of Magento 2.
Section: The <section> tag creates the child links under the main tab. You can add any number of sections under one tab. For example, Catalog, Inventory, XML Sitemape, etc, are sections under the CATALOG tab.
Group: The <group> tag is a child of <section>. Group bunches the number of fields into one. For example, “Product Fields Auto-Generation”, “Storefront”, “Product Reviews”, etc are groups of Catalog section
Field: The <field> tag is the actual store configuration setting of the Magento module. You can add any number of fields under the <group> tag and that will be a bunch in one group.
Below is the result of the above sample file.

How to set Default Values to System Configurations Settings
You can set it from etc/config.php file of module.

