<?xml version='1.0' encoding='utf-8'?>
<FilingSummary>
  <Version>3.26.1</Version>
  <ProcessingTime/>
  <ReportFormat>html</ReportFormat>
  <ContextCount>498</ContextCount>
  <ElementCount>634</ElementCount>
  <EntityCount>1</EntityCount>
  <FootnotesReported>true</FootnotesReported>
  <SegmentCount>126</SegmentCount>
  <ScenarioCount>0</ScenarioCount>
  <TuplesReported>false</TuplesReported>
  <UnitCount>11</UnitCount>
  <MyReports>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R1.htm</HtmlFileName>
      <LongName>995200090 - Document - Document and Entity Information</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DocumentDocumentAndEntityInformation</Role>
      <ShortName>Document and Entity Information</ShortName>
      <MenuCategory>Cover</MenuCategory>
      <Position>1</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R2.htm</HtmlFileName>
      <LongName>995200100 - Statement - CONSOLIDATED BALANCE SHEETS</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/StatementConsolidatedBalanceSheets</Role>
      <ShortName>CONSOLIDATED BALANCE SHEETS</ShortName>
      <MenuCategory>Statements</MenuCategory>
      <Position>2</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R3.htm</HtmlFileName>
      <LongName>995200105 - Statement - CONSOLIDATED BALANCE SHEETS (Parenthetical)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/StatementConsolidatedBalanceSheetsParenthetical</Role>
      <ShortName>CONSOLIDATED BALANCE SHEETS (Parenthetical)</ShortName>
      <MenuCategory>Statements</MenuCategory>
      <Position>3</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R4.htm</HtmlFileName>
      <LongName>995200200 - Statement - CONSOLIDATED STATEMENTS OF COMPREHENSIVE INCOME</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/StatementConsolidatedStatementsOfComprehensiveIncome</Role>
      <ShortName>CONSOLIDATED STATEMENTS OF COMPREHENSIVE INCOME</ShortName>
      <MenuCategory>Statements</MenuCategory>
      <Position>4</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R5.htm</HtmlFileName>
      <LongName>995200205 - Statement - CONSOLIDATED STATEMENTS OF COMPREHENSIVE INCOME (Parenthetical)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/StatementConsolidatedStatementsOfComprehensiveIncomeParenthetical</Role>
      <ShortName>CONSOLIDATED STATEMENTS OF COMPREHENSIVE INCOME (Parenthetical)</ShortName>
      <MenuCategory>Statements</MenuCategory>
      <Position>5</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R6.htm</HtmlFileName>
      <LongName>995200300 - Statement - CONSOLIDATED STATEMENTS OF CHANGES IN SHAREHOLDERS' EQUITY</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/StatementConsolidatedStatementsOfChangesInShareholdersEquity</Role>
      <ShortName>CONSOLIDATED STATEMENTS OF CHANGES IN SHAREHOLDERS' EQUITY</ShortName>
      <MenuCategory>Statements</MenuCategory>
      <Position>6</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R7.htm</HtmlFileName>
      <LongName>995200305 - Statement - CONSOLIDATED STATEMENTS OF CHANGES IN SHAREHOLDERS' EQUITY (Parenthetical)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/StatementConsolidatedStatementsOfChangesInShareholdersEquityParenthetical</Role>
      <ShortName>CONSOLIDATED STATEMENTS OF CHANGES IN SHAREHOLDERS' EQUITY (Parenthetical)</ShortName>
      <MenuCategory>Statements</MenuCategory>
      <Position>7</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R8.htm</HtmlFileName>
      <LongName>995200400 - Statement - CONSOLIDATED STATEMENTS OF CASH FLOWS</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/StatementConsolidatedStatementsOfCashFlows</Role>
      <ShortName>CONSOLIDATED STATEMENTS OF CASH FLOWS</ShortName>
      <MenuCategory>Statements</MenuCategory>
      <Position>8</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R9.htm</HtmlFileName>
      <LongName>995200405 - Statement - CONSOLIDATED STATEMENTS OF CASH FLOWS (Parenthetical)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/StatementConsolidatedStatementsOfCashFlowsParenthetical</Role>
      <ShortName>CONSOLIDATED STATEMENTS OF CASH FLOWS (Parenthetical)</ShortName>
      <MenuCategory>Statements</MenuCategory>
      <Position>9</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R10.htm</HtmlFileName>
      <LongName>995210101 - Disclosure - Organization and principal activities</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureOrganizationAndPrincipalActivities</Role>
      <ShortName>Organization and principal activities</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>10</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R11.htm</HtmlFileName>
      <LongName>995210201 - Disclosure - Summary of significant accounting policies</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureSummaryOfSignificantAccountingPolicies</Role>
      <ShortName>Summary of significant accounting policies</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>11</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R12.htm</HtmlFileName>
      <LongName>995210301 - Disclosure - Fair value of assets and liabilities</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureFairValueOfAssetsAndLiabilities</Role>
      <ShortName>Fair value of assets and liabilities</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>12</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R13.htm</HtmlFileName>
      <LongName>995210401 - Disclosure - Prepaid expenses and other current assets</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosurePrepaidExpensesAndOtherCurrentAssets</Role>
      <ShortName>Prepaid expenses and other current assets</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>13</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R14.htm</HtmlFileName>
      <LongName>995210501 - Disclosure - Deposits to institutional cooperators, net</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureDepositsToInstitutionalCooperatorsNet</Role>
      <ShortName>Deposits to institutional cooperators, net</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>14</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R15.htm</HtmlFileName>
      <LongName>995210601 - Disclosure - Property and equipment, net</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosurePropertyAndEquipmentNet</Role>
      <ShortName>Property and equipment, net</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>15</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R16.htm</HtmlFileName>
      <LongName>995210701 - Disclosure - Intangible assets, net</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureIntangibleAssetsNet</Role>
      <ShortName>Intangible assets, net</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>16</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R17.htm</HtmlFileName>
      <LongName>995210801 - Disclosure - Short - term borrowings</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureShortTermBorrowings</Role>
      <ShortName>Short - term borrowings</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>17</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R18.htm</HtmlFileName>
      <LongName>995210901 - Disclosure - Financial investments</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureFinancialInvestments</Role>
      <ShortName>Financial investments</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>18</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R19.htm</HtmlFileName>
      <LongName>995211001 - Disclosure - Long-term investments</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureLongTermInvestments</Role>
      <ShortName>Long-term investments</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>19</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R20.htm</HtmlFileName>
      <LongName>995211101 - Disclosure - Accrued expenses and other current liabilities</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureAccruedExpensesAndOtherCurrentLiabilities</Role>
      <ShortName>Accrued expenses and other current liabilities</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>20</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R21.htm</HtmlFileName>
      <LongName>995211201 - Disclosure - Guarantee liabilities</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureGuaranteeLiabilities</Role>
      <ShortName>Guarantee liabilities</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>21</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R22.htm</HtmlFileName>
      <LongName>995211301 - Disclosure - Related party balances and transactions</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureRelatedPartyBalancesAndTransactions</Role>
      <ShortName>Related party balances and transactions</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>22</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R23.htm</HtmlFileName>
      <LongName>995211401 - Disclosure - Income taxes</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureIncomeTaxes</Role>
      <ShortName>Income taxes</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>23</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R24.htm</HtmlFileName>
      <LongName>995211501 - Disclosure - Net income per share and net income attributable to common stockholders</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureNetIncomePerShareAndNetIncomeAttributableToCommonStockholders</Role>
      <ShortName>Net income per share and net income attributable to common stockholders</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>24</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R25.htm</HtmlFileName>
      <LongName>995211601 - Disclosure - Share-based compensation</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureShareBasedCompensation</Role>
      <ShortName>Share-based compensation</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>25</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R26.htm</HtmlFileName>
      <LongName>995211701 - Disclosure - Statutory reserves and restricted net assets</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureStatutoryReservesAndRestrictedNetAssets</Role>
      <ShortName>Statutory reserves and restricted net assets</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>26</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R27.htm</HtmlFileName>
      <LongName>995211801 - Disclosure - Commitments and contingencies</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureCommitmentsAndContingencies</Role>
      <ShortName>Commitments and contingencies</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>27</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R28.htm</HtmlFileName>
      <LongName>995211901 - Disclosure - Subsequent events</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureSubsequentEvents</Role>
      <ShortName>Subsequent events</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>28</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R29.htm</HtmlFileName>
      <LongName>995212001 - Disclosure - SCHEDULE I - CONDENSED FINANCIAL INFORMATION OF PARENT COMPANY</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureScheduleICondensedFinancialInformationOfParentCompany</Role>
      <ShortName>SCHEDULE I - CONDENSED FINANCIAL INFORMATION OF PARENT COMPANY</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>29</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R30.htm</HtmlFileName>
      <LongName>995410 - Disclosure - Pay vs Performance Disclosure</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://xbrl.sec.gov/ecd/role/PvpDisclosure</Role>
      <ShortName>Pay vs Performance Disclosure</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>30</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R31.htm</HtmlFileName>
      <LongName>995447 - Disclosure - Insider Trading Policies and Procedures</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://xbrl.sec.gov/ecd/role/InsiderTradingPoliciesProc</Role>
      <ShortName>Insider Trading Policies and Procedures</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>31</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R32.htm</HtmlFileName>
      <LongName>995550 - Disclosure - Cybersecurity Risk Management and Strategy Disclosure</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://xbrl.sec.gov/cyd/role/CybersecurityRiskManagementAndStrategyDisclosure</Role>
      <ShortName>Cybersecurity Risk Management and Strategy Disclosure</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>32</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R33.htm</HtmlFileName>
      <LongName>99920202 - Disclosure - Summary of significant accounting policies (Policies)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureSummaryOfSignificantAccountingPoliciesPolicies</Role>
      <ShortName>Summary of significant accounting policies (Policies)</ShortName>
      <MenuCategory>Policies</MenuCategory>
      <Position>33</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R34.htm</HtmlFileName>
      <LongName>99930103 - Disclosure - Organization and principal activities (Tables)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureOrganizationAndPrincipalActivitiesTables</Role>
      <ShortName>Organization and principal activities (Tables)</ShortName>
      <MenuCategory>Tables</MenuCategory>
      <ParentRole>http://ir.xiaoyinggroup.com/role/DisclosureOrganizationAndPrincipalActivities</ParentRole>
      <Position>34</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R35.htm</HtmlFileName>
      <LongName>99930203 - Disclosure - Summary of significant accounting policies (Tables)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureSummaryOfSignificantAccountingPoliciesTables</Role>
      <ShortName>Summary of significant accounting policies (Tables)</ShortName>
      <MenuCategory>Tables</MenuCategory>
      <ParentRole>http://ir.xiaoyinggroup.com/role/DisclosureSummaryOfSignificantAccountingPolicies</ParentRole>
      <Position>35</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R36.htm</HtmlFileName>
      <LongName>99930303 - Disclosure - Fair value of assets and liabilities (Tables)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureFairValueOfAssetsAndLiabilitiesTables</Role>
      <ShortName>Fair value of assets and liabilities (Tables)</ShortName>
      <MenuCategory>Tables</MenuCategory>
      <ParentRole>http://ir.xiaoyinggroup.com/role/DisclosureFairValueOfAssetsAndLiabilities</ParentRole>
      <Position>36</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R37.htm</HtmlFileName>
      <LongName>99930403 - Disclosure - Prepaid expenses and other current assets (Tables)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosurePrepaidExpensesAndOtherCurrentAssetsTables</Role>
      <ShortName>Prepaid expenses and other current assets (Tables)</ShortName>
      <MenuCategory>Tables</MenuCategory>
      <ParentRole>http://ir.xiaoyinggroup.com/role/DisclosurePrepaidExpensesAndOtherCurrentAssets</ParentRole>
      <Position>37</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R38.htm</HtmlFileName>
      <LongName>99930503 - Disclosure - Deposits to institutional cooperators, net (Tables)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureDepositsToInstitutionalCooperatorsNetTables</Role>
      <ShortName>Deposits to institutional cooperators, net (Tables)</ShortName>
      <MenuCategory>Tables</MenuCategory>
      <ParentRole>http://ir.xiaoyinggroup.com/role/DisclosureDepositsToInstitutionalCooperatorsNet</ParentRole>
      <Position>38</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R39.htm</HtmlFileName>
      <LongName>99930603 - Disclosure - Property and equipment, net (Tables)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosurePropertyAndEquipmentNetTables</Role>
      <ShortName>Property and equipment, net (Tables)</ShortName>
      <MenuCategory>Tables</MenuCategory>
      <ParentRole>http://ir.xiaoyinggroup.com/role/DisclosurePropertyAndEquipmentNet</ParentRole>
      <Position>39</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R40.htm</HtmlFileName>
      <LongName>99930703 - Disclosure - Intangible assets, net (Tables)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureIntangibleAssetsNetTables</Role>
      <ShortName>Intangible assets, net (Tables)</ShortName>
      <MenuCategory>Tables</MenuCategory>
      <ParentRole>http://ir.xiaoyinggroup.com/role/DisclosureIntangibleAssetsNet</ParentRole>
      <Position>40</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R41.htm</HtmlFileName>
      <LongName>99930903 - Disclosure - Financial investments (Tables)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureFinancialInvestmentsTables</Role>
      <ShortName>Financial investments (Tables)</ShortName>
      <MenuCategory>Tables</MenuCategory>
      <ParentRole>http://ir.xiaoyinggroup.com/role/DisclosureFinancialInvestments</ParentRole>
      <Position>41</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R42.htm</HtmlFileName>
      <LongName>99931003 - Disclosure - Long-term investments (Tables)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureLongTermInvestmentsTables</Role>
      <ShortName>Long-term investments (Tables)</ShortName>
      <MenuCategory>Tables</MenuCategory>
      <ParentRole>http://ir.xiaoyinggroup.com/role/DisclosureLongTermInvestments</ParentRole>
      <Position>42</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R43.htm</HtmlFileName>
      <LongName>99931103 - Disclosure - Accrued expenses and other current liabilities (Tables)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureAccruedExpensesAndOtherCurrentLiabilitiesTables</Role>
      <ShortName>Accrued expenses and other current liabilities (Tables)</ShortName>
      <MenuCategory>Tables</MenuCategory>
      <ParentRole>http://ir.xiaoyinggroup.com/role/DisclosureAccruedExpensesAndOtherCurrentLiabilities</ParentRole>
      <Position>43</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R44.htm</HtmlFileName>
      <LongName>99931203 - Disclosure - Guarantee liabilities (Tables)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureGuaranteeLiabilitiesTables</Role>
      <ShortName>Guarantee liabilities (Tables)</ShortName>
      <MenuCategory>Tables</MenuCategory>
      <ParentRole>http://ir.xiaoyinggroup.com/role/DisclosureGuaranteeLiabilities</ParentRole>
      <Position>44</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R45.htm</HtmlFileName>
      <LongName>99931403 - Disclosure - Income taxes (Tables)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureIncomeTaxesTables</Role>
      <ShortName>Income taxes (Tables)</ShortName>
      <MenuCategory>Tables</MenuCategory>
      <ParentRole>http://ir.xiaoyinggroup.com/role/DisclosureIncomeTaxes</ParentRole>
      <Position>45</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R46.htm</HtmlFileName>
      <LongName>99931503 - Disclosure - Net income per share and net income attributable to common stockholders (Tables)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureNetIncomePerShareAndNetIncomeAttributableToCommonStockholdersTables</Role>
      <ShortName>Net income per share and net income attributable to common stockholders (Tables)</ShortName>
      <MenuCategory>Tables</MenuCategory>
      <ParentRole>http://ir.xiaoyinggroup.com/role/DisclosureNetIncomePerShareAndNetIncomeAttributableToCommonStockholders</ParentRole>
      <Position>46</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R47.htm</HtmlFileName>
      <LongName>99931603 - Disclosure - Share-based compensation (Tables)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureShareBasedCompensationTables</Role>
      <ShortName>Share-based compensation (Tables)</ShortName>
      <MenuCategory>Tables</MenuCategory>
      <ParentRole>http://ir.xiaoyinggroup.com/role/DisclosureShareBasedCompensation</ParentRole>
      <Position>47</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R48.htm</HtmlFileName>
      <LongName>99932003 - Disclosure - SCHEDULE I - CONDENSED FINANCIAL INFORMATION OF PARENT COMPANY (Tables)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureScheduleICondensedFinancialInformationOfParentCompanyTables</Role>
      <ShortName>SCHEDULE I - CONDENSED FINANCIAL INFORMATION OF PARENT COMPANY (Tables)</ShortName>
      <MenuCategory>Tables</MenuCategory>
      <ParentRole>http://ir.xiaoyinggroup.com/role/DisclosureScheduleICondensedFinancialInformationOfParentCompany</ParentRole>
      <Position>48</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R49.htm</HtmlFileName>
      <LongName>99940101 - Disclosure - Organization and principal activities (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureOrganizationAndPrincipalActivitiesDetails</Role>
      <ShortName>Organization and principal activities (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <ParentRole>http://ir.xiaoyinggroup.com/role/DisclosureOrganizationAndPrincipalActivitiesTables</ParentRole>
      <Position>49</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R50.htm</HtmlFileName>
      <LongName>99940201 - Disclosure - Summary of significant accounting policies - Variable interest entity (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureSummaryOfSignificantAccountingPoliciesVariableInterestEntityDetails</Role>
      <ShortName>Summary of significant accounting policies - Variable interest entity (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>50</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R51.htm</HtmlFileName>
      <LongName>99940202 - Disclosure - Summary of significant accounting policies - Consolidated Trusts (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureSummaryOfSignificantAccountingPoliciesConsolidatedTrustsDetails</Role>
      <ShortName>Summary of significant accounting policies - Consolidated Trusts (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>51</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R52.htm</HtmlFileName>
      <LongName>99940203 - Disclosure - Summary of significant accounting policies - Revenue recognition (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureSummaryOfSignificantAccountingPoliciesRevenueRecognitionDetails</Role>
      <ShortName>Summary of significant accounting policies - Revenue recognition (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>52</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R53.htm</HtmlFileName>
      <LongName>99940204 - Disclosure - Summary of significant accounting policies - Guarantee liabilities and Financial guarantee derivative (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureSummaryOfSignificantAccountingPoliciesGuaranteeLiabilitiesAndFinancialGuaranteeDerivativeDetails</Role>
      <ShortName>Summary of significant accounting policies - Guarantee liabilities and Financial guarantee derivative (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>53</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R54.htm</HtmlFileName>
      <LongName>99940205 - Disclosure - Summary of significant accounting policies - AR and contract assets and allowance for uncollectible AR and contract assets (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureSummaryOfSignificantAccountingPoliciesArAndContractAssetsAndAllowanceForUncollectibleArAndContractAssetsDetails</Role>
      <ShortName>Summary of significant accounting policies - AR and contract assets and allowance for uncollectible AR and contract assets (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>54</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R55.htm</HtmlFileName>
      <LongName>99940206 - Disclosure - Summary of significant accounting policies - Loan receivables from Xiaoying Credit Loans and other loans, net (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureSummaryOfSignificantAccountingPoliciesLoanReceivablesFromXiaoyingCreditLoansAndOtherLoansNetDetails</Role>
      <ShortName>Summary of significant accounting policies - Loan receivables from Xiaoying Credit Loans and other loans, net (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>55</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R56.htm</HtmlFileName>
      <LongName>99940207 - Disclosure - Summary of significant accounting policies - Loan receivables from Xiaoying Credit Loans and other loans originated and retained by the Company (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureSummaryOfSignificantAccountingPoliciesLoanReceivablesFromXiaoyingCreditLoansAndOtherLoansOriginatedAndRetainedByCompanyDetails</Role>
      <ShortName>Summary of significant accounting policies - Loan receivables from Xiaoying Credit Loans and other loans originated and retained by the Company (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>56</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R57.htm</HtmlFileName>
      <LongName>99940208 - Disclosure - Summary of significant accounting policies - Movement of provision for loan receivables from Xiaoying Credit Loans and other loans (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureSummaryOfSignificantAccountingPoliciesMovementOfProvisionForLoanReceivablesFromXiaoyingCreditLoansAndOtherLoansDetails</Role>
      <ShortName>Summary of significant accounting policies - Movement of provision for loan receivables from Xiaoying Credit Loans and other loans (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>57</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R58.htm</HtmlFileName>
      <LongName>99940209 - Disclosure - Summary of significant accounting policies - Aging of loan receivables from Xiaoying Credit Loans and other loans (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureSummaryOfSignificantAccountingPoliciesAgingOfLoanReceivablesFromXiaoyingCreditLoansAndOtherLoansDetails</Role>
      <ShortName>Summary of significant accounting policies - Aging of loan receivables from Xiaoying Credit Loans and other loans (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>58</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R59.htm</HtmlFileName>
      <LongName>99940210 - Disclosure - Summary of significant accounting policies - Past due days credit quality (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureSummaryOfSignificantAccountingPoliciesPastDueDaysCreditQualityDetails</Role>
      <ShortName>Summary of significant accounting policies - Past due days credit quality (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>59</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R60.htm</HtmlFileName>
      <LongName>99940211 - Disclosure - Summary of significant accounting policies - Loan receivable from Xiaoying Housing Loans, net (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureSummaryOfSignificantAccountingPoliciesLoanReceivableFromXiaoyingHousingLoansNetDetails</Role>
      <ShortName>Summary of significant accounting policies - Loan receivable from Xiaoying Housing Loans, net (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>60</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R61.htm</HtmlFileName>
      <LongName>99940212 - Disclosure - Summary of significant accounting policies - Others (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureSummaryOfSignificantAccountingPoliciesOthersDetails</Role>
      <ShortName>Summary of significant accounting policies - Others (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <ParentRole>http://ir.xiaoyinggroup.com/role/DisclosureSummaryOfSignificantAccountingPoliciesTables</ParentRole>
      <Position>61</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R62.htm</HtmlFileName>
      <LongName>99940213 - Disclosure - Summary of significant accounting policies - Property and equipment, net, Intangible assets and Impairment long-lived assets (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureSummaryOfSignificantAccountingPoliciesPropertyAndEquipmentNetIntangibleAssetsAndImpairmentLongLivedAssetsDetails</Role>
      <ShortName>Summary of significant accounting policies - Property and equipment, net, Intangible assets and Impairment long-lived assets (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>62</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R63.htm</HtmlFileName>
      <LongName>99940214 - Disclosure - Summary of significant accounting policies - Leases (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureSummaryOfSignificantAccountingPoliciesLeasesDetails</Role>
      <ShortName>Summary of significant accounting policies - Leases (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <ParentRole>http://ir.xiaoyinggroup.com/role/DisclosureSummaryOfSignificantAccountingPoliciesTables</ParentRole>
      <Position>63</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R64.htm</HtmlFileName>
      <LongName>99940215 - Disclosure - Summary of significant accounting policies - Certain risks and concentrations (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureSummaryOfSignificantAccountingPoliciesCertainRisksAndConcentrationsDetails</Role>
      <ShortName>Summary of significant accounting policies - Certain risks and concentrations (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>64</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R65.htm</HtmlFileName>
      <LongName>99940301 - Disclosure - Fair value of assets and liabilities - Financial Instruments Recorded at Fair Value on a Recurring Basis (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureFairValueOfAssetsAndLiabilitiesFinancialInstrumentsRecordedAtFairValueOnRecurringBasisDetails</Role>
      <ShortName>Fair value of assets and liabilities - Financial Instruments Recorded at Fair Value on a Recurring Basis (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>65</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R66.htm</HtmlFileName>
      <LongName>99940302 - Disclosure - Fair value of assets and liabilities - Notional Amount/ Maximum Potential Payout, Fair Value (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureFairValueOfAssetsAndLiabilitiesNotionalAmountMaximumPotentialPayoutFairValueDetails</Role>
      <ShortName>Fair value of assets and liabilities - Notional Amount/ Maximum Potential Payout, Fair Value (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>66</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R67.htm</HtmlFileName>
      <LongName>99940303 - Disclosure - Fair value of assets and liabilities - Reconciliation of financial guarantee derivatives (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureFairValueOfAssetsAndLiabilitiesReconciliationOfFinancialGuaranteeDerivativesDetails</Role>
      <ShortName>Fair value of assets and liabilities - Reconciliation of financial guarantee derivatives (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>67</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R68.htm</HtmlFileName>
      <LongName>99940401 - Disclosure - Prepaid expenses and other current assets (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosurePrepaidExpensesAndOtherCurrentAssetsDetails</Role>
      <ShortName>Prepaid expenses and other current assets (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <ParentRole>http://ir.xiaoyinggroup.com/role/DisclosurePrepaidExpensesAndOtherCurrentAssetsTables</ParentRole>
      <Position>68</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R69.htm</HtmlFileName>
      <LongName>99940501 - Disclosure - Deposits to institutional cooperators, net (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureDepositsToInstitutionalCooperatorsNetDetails</Role>
      <ShortName>Deposits to institutional cooperators, net (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <ParentRole>http://ir.xiaoyinggroup.com/role/DisclosureDepositsToInstitutionalCooperatorsNetTables</ParentRole>
      <Position>69</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R70.htm</HtmlFileName>
      <LongName>99940502 - Disclosure - Deposits to institutional cooperators, net - Movement of the provision (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureDepositsToInstitutionalCooperatorsNetMovementOfProvisionDetails</Role>
      <ShortName>Deposits to institutional cooperators, net - Movement of the provision (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>70</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R71.htm</HtmlFileName>
      <LongName>99940601 - Disclosure - Property and equipment, net (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosurePropertyAndEquipmentNetDetails</Role>
      <ShortName>Property and equipment, net (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <ParentRole>http://ir.xiaoyinggroup.com/role/DisclosurePropertyAndEquipmentNetTables</ParentRole>
      <Position>71</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R72.htm</HtmlFileName>
      <LongName>99940701 - Disclosure - Intangible assets, net (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureIntangibleAssetsNetDetails</Role>
      <ShortName>Intangible assets, net (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <ParentRole>http://ir.xiaoyinggroup.com/role/DisclosureIntangibleAssetsNetTables</ParentRole>
      <Position>72</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R73.htm</HtmlFileName>
      <LongName>99940801 - Disclosure - Short - term borrowings (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureShortTermBorrowingsDetails</Role>
      <ShortName>Short - term borrowings (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <ParentRole>http://ir.xiaoyinggroup.com/role/DisclosureShortTermBorrowings</ParentRole>
      <Position>73</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R74.htm</HtmlFileName>
      <LongName>99940901 - Disclosure - Financial investments (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureFinancialInvestmentsDetails</Role>
      <ShortName>Financial investments (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <ParentRole>http://ir.xiaoyinggroup.com/role/DisclosureFinancialInvestmentsTables</ParentRole>
      <Position>74</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R75.htm</HtmlFileName>
      <LongName>99940902 - Disclosure - Financial investments - Carrying value of investments in VC funds (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureFinancialInvestmentsCarryingValueOfInvestmentsInVcFundsDetails</Role>
      <ShortName>Financial investments - Carrying value of investments in VC funds (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>75</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R76.htm</HtmlFileName>
      <LongName>99940903 - Disclosure - Financial investments - Combined financial information for the VC funds (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureFinancialInvestmentsCombinedFinancialInformationForVcFundsDetails</Role>
      <ShortName>Financial investments - Combined financial information for the VC funds (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>76</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R77.htm</HtmlFileName>
      <LongName>99940904 - Disclosure - Financial investments - Summary of investments measured at cost minus impairment (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureFinancialInvestmentsSummaryOfInvestmentsMeasuredAtCostMinusImpairmentDetails</Role>
      <ShortName>Financial investments - Summary of investments measured at cost minus impairment (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>77</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R78.htm</HtmlFileName>
      <LongName>99940905 - Disclosure - Financial investments - Summary of investments in VC funds in the form of partnership measured at fair value (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureFinancialInvestmentsSummaryOfInvestmentsInVcFundsInFormOfPartnershipMeasuredAtFairValueDetails</Role>
      <ShortName>Financial investments - Summary of investments in VC funds in the form of partnership measured at fair value (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>78</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R79.htm</HtmlFileName>
      <LongName>99940906 - Disclosure - Financial investments - Summary investments measured under available-for-sale (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureFinancialInvestmentsSummaryInvestmentsMeasuredUnderAvailableForSaleDetails</Role>
      <ShortName>Financial investments - Summary investments measured under available-for-sale (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>79</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R80.htm</HtmlFileName>
      <LongName>99940907 - Disclosure - Financial investments - Financial investments accounted under trading model (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureFinancialInvestmentsFinancialInvestmentsAccountedUnderTradingModelDetails</Role>
      <ShortName>Financial investments - Financial investments accounted under trading model (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>80</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R81.htm</HtmlFileName>
      <LongName>99940908 - Disclosure - Financial investments - Summary of investments measured under amortization cost (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureFinancialInvestmentsSummaryOfInvestmentsMeasuredUnderAmortizationCostDetails</Role>
      <ShortName>Financial investments - Summary of investments measured under amortization cost (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>81</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R82.htm</HtmlFileName>
      <LongName>99941001 - Disclosure - Long-term investments - Combined financial information for the investee companies (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureLongTermInvestmentsCombinedFinancialInformationForInvesteeCompaniesDetails</Role>
      <ShortName>Long-term investments - Combined financial information for the investee companies (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>82</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R83.htm</HtmlFileName>
      <LongName>99941002 - Disclosure - Long-term investments - Additional Information (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureLongTermInvestmentsAdditionalInformationDetails</Role>
      <ShortName>Long-term investments - Additional Information (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>83</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R84.htm</HtmlFileName>
      <LongName>99941101 - Disclosure - Accrued expenses and other current liabilities (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureAccruedExpensesAndOtherCurrentLiabilitiesDetails</Role>
      <ShortName>Accrued expenses and other current liabilities (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <ParentRole>http://ir.xiaoyinggroup.com/role/DisclosureAccruedExpensesAndOtherCurrentLiabilitiesTables</ParentRole>
      <Position>84</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R85.htm</HtmlFileName>
      <LongName>99941201 - Disclosure - Guarantee liabilities - Activities of the Group's obligations associated with the deferred guarantee income (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureGuaranteeLiabilitiesActivitiesOfGroupSObligationsAssociatedWithDeferredGuaranteeIncomeDetails</Role>
      <ShortName>Guarantee liabilities - Activities of the Group's obligations associated with the deferred guarantee income (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>85</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R86.htm</HtmlFileName>
      <LongName>99941202 - Disclosure - Guarantee liabilities - Movement of contingent guarantee liabilities (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureGuaranteeLiabilitiesMovementOfContingentGuaranteeLiabilitiesDetails</Role>
      <ShortName>Guarantee liabilities - Movement of contingent guarantee liabilities (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>86</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R87.htm</HtmlFileName>
      <LongName>99941301 - Disclosure - Related party balances and transactions (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureRelatedPartyBalancesAndTransactionsDetails</Role>
      <ShortName>Related party balances and transactions (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <ParentRole>http://ir.xiaoyinggroup.com/role/DisclosureRelatedPartyBalancesAndTransactions</ParentRole>
      <Position>87</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R88.htm</HtmlFileName>
      <LongName>99941401 - Disclosure - Income taxes - Tax rates (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureIncomeTaxesTaxRatesDetails</Role>
      <ShortName>Income taxes - Tax rates (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>88</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R89.htm</HtmlFileName>
      <LongName>99941402 - Disclosure - Income taxes - Current and deferred component of income tax expense (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureIncomeTaxesCurrentAndDeferredComponentOfIncomeTaxExpenseDetails</Role>
      <ShortName>Income taxes - Current and deferred component of income tax expense (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>89</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R90.htm</HtmlFileName>
      <LongName>99941403 - Disclosure - Income taxes - Pre-tax income (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureIncomeTaxesPreTaxIncomeDetails</Role>
      <ShortName>Income taxes - Pre-tax income (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>90</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R91.htm</HtmlFileName>
      <LongName>99941404 - Disclosure - Income taxes - Reconciliation between the income taxes expense (benefit) and provision for income taxes (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureIncomeTaxesReconciliationBetweenIncomeTaxesExpenseBenefitAndProvisionForIncomeTaxesDetails</Role>
      <ShortName>Income taxes - Reconciliation between the income taxes expense (benefit) and provision for income taxes (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>91</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R92.htm</HtmlFileName>
      <LongName>99941405 - Disclosure - Income taxes - Effect of preferential tax rate (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureIncomeTaxesEffectOfPreferentialTaxRateDetails</Role>
      <ShortName>Income taxes - Effect of preferential tax rate (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>92</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R93.htm</HtmlFileName>
      <LongName>99941406 - Disclosure - Income taxes - Components of the deferred tax assets and liabilities (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureIncomeTaxesComponentsOfDeferredTaxAssetsAndLiabilitiesDetails</Role>
      <ShortName>Income taxes - Components of the deferred tax assets and liabilities (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>93</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R94.htm</HtmlFileName>
      <LongName>99941407 - Disclosure - Income taxes - Movement of the valuation allowance (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureIncomeTaxesMovementOfValuationAllowanceDetails</Role>
      <ShortName>Income taxes - Movement of the valuation allowance (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>94</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R95.htm</HtmlFileName>
      <LongName>99941408 - Disclosure - Income taxes - Unrecognized tax benefit (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureIncomeTaxesUnrecognizedTaxBenefitDetails</Role>
      <ShortName>Income taxes - Unrecognized tax benefit (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>95</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R96.htm</HtmlFileName>
      <LongName>99941501 - Disclosure - Net income per share and net income attributable to common stockholders (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureNetIncomePerShareAndNetIncomeAttributableToCommonStockholdersDetails</Role>
      <ShortName>Net income per share and net income attributable to common stockholders (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <ParentRole>http://ir.xiaoyinggroup.com/role/DisclosureNetIncomePerShareAndNetIncomeAttributableToCommonStockholdersTables</ParentRole>
      <Position>96</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R97.htm</HtmlFileName>
      <LongName>99941502 - Disclosure - Net income per share and net income attributable to common stockholders - Anti-dilutive shares (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureNetIncomePerShareAndNetIncomeAttributableToCommonStockholdersAntiDilutiveSharesDetails</Role>
      <ShortName>Net income per share and net income attributable to common stockholders - Anti-dilutive shares (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>97</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R98.htm</HtmlFileName>
      <LongName>99941601 - Disclosure - Share-based compensation (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureShareBasedCompensationDetails</Role>
      <ShortName>Share-based compensation (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <ParentRole>http://ir.xiaoyinggroup.com/role/DisclosureShareBasedCompensationTables</ParentRole>
      <Position>98</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R99.htm</HtmlFileName>
      <LongName>99941602 - Disclosure - Share-based compensation - Stock option valuation (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureShareBasedCompensationStockOptionValuationDetails</Role>
      <ShortName>Share-based compensation - Stock option valuation (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>99</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R100.htm</HtmlFileName>
      <LongName>99941603 - Disclosure - Share-based compensation - Stock option activity (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureShareBasedCompensationStockOptionActivityDetails</Role>
      <ShortName>Share-based compensation - Stock option activity (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>100</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R101.htm</HtmlFileName>
      <LongName>99941604 - Disclosure - Share-based compensation - Compensation cost (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureShareBasedCompensationCompensationCostDetails</Role>
      <ShortName>Share-based compensation - Compensation cost (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>101</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R102.htm</HtmlFileName>
      <LongName>99941605 - Disclosure - Share-based compensation - Restricted stocks unit (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureShareBasedCompensationRestrictedStocksUnitDetails</Role>
      <ShortName>Share-based compensation - Restricted stocks unit (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>102</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R103.htm</HtmlFileName>
      <LongName>99941701 - Disclosure - Statutory reserves and restricted net assets (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureStatutoryReservesAndRestrictedNetAssetsDetails</Role>
      <ShortName>Statutory reserves and restricted net assets (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <ParentRole>http://ir.xiaoyinggroup.com/role/DisclosureStatutoryReservesAndRestrictedNetAssets</ParentRole>
      <Position>103</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R104.htm</HtmlFileName>
      <LongName>99941901 - Disclosure - Subsequent events (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureSubsequentEventsDetails</Role>
      <ShortName>Subsequent events (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <ParentRole>http://ir.xiaoyinggroup.com/role/DisclosureSubsequentEvents</ParentRole>
      <Position>104</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R105.htm</HtmlFileName>
      <LongName>99942001 - Disclosure - SCHEDULE I - CONDENSED FINANCIAL INFORMATION OF PARENT COMPANY - BALANCE SHEETS (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureScheduleICondensedFinancialInformationOfParentCompanyBalanceSheetsDetails</Role>
      <ShortName>SCHEDULE I - CONDENSED FINANCIAL INFORMATION OF PARENT COMPANY - BALANCE SHEETS (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>105</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R106.htm</HtmlFileName>
      <LongName>99942002 - Disclosure - SCHEDULE I - CONDENSED FINANCIAL INFORMATION OF PARENT COMPANY - STATEMENTS OF COMPREHENSIVE INCOME (LOSS) (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureScheduleICondensedFinancialInformationOfParentCompanyStatementsOfComprehensiveIncomeLossDetails</Role>
      <ShortName>SCHEDULE I - CONDENSED FINANCIAL INFORMATION OF PARENT COMPANY - STATEMENTS OF COMPREHENSIVE INCOME (LOSS) (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>106</Position>
    </Report>
    <Report instance="xyf-20251231x20f.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R107.htm</HtmlFileName>
      <LongName>99942003 - Disclosure - SCHEDULE I - CONDENSED FINANCIAL INFORMATION OF PARENT COMPANY - STATEMENT OF CASH FLOWS (Details)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://ir.xiaoyinggroup.com/role/DisclosureScheduleICondensedFinancialInformationOfParentCompanyStatementOfCashFlowsDetails</Role>
      <ShortName>SCHEDULE I - CONDENSED FINANCIAL INFORMATION OF PARENT COMPANY - STATEMENT OF CASH FLOWS (Details)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>107</Position>
    </Report>
    <Report>
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <LongName>All Reports</LongName>
      <ReportType>Book</ReportType>
      <ShortName>All Reports</ShortName>
    </Report>
  </MyReports>
  <InputFiles>
    <File>xyf-20251231.xsd</File>
    <File>xyf-20251231_cal.xml</File>
    <File>xyf-20251231_def.xml</File>
    <File>xyf-20251231_lab.xml</File>
    <File>xyf-20251231_pre.xml</File>
    <File doctype="20-F" isDefinitelyFs="true" isUsgaap="true" original="xyf-20251231x20f.htm">xyf-20251231x20f.htm</File>
  </InputFiles>
  <SupplementalFiles>
    <File>xyf-20251231x20f003.jpg</File>
    <File>xyf-20251231x20f007.jpg</File>
    <File>xyf-20251231x20f010.jpg</File>
    <File>xyf-20251231x20f018.jpg</File>
  </SupplementalFiles>
  <BaseTaxonomies>
    <BaseTaxonomy items="5">http://fasb.org/srt/2025</BaseTaxonomy>
    <BaseTaxonomy items="2160">http://fasb.org/us-gaap/2025</BaseTaxonomy>
    <BaseTaxonomy items="15">http://xbrl.sec.gov/cyd/2025</BaseTaxonomy>
    <BaseTaxonomy items="54">http://xbrl.sec.gov/dei/2025</BaseTaxonomy>
    <BaseTaxonomy items="1">http://xbrl.sec.gov/ecd/2025</BaseTaxonomy>
  </BaseTaxonomies>
  <HasPresentationLinkbase>true</HasPresentationLinkbase>
  <HasCalculationLinkbase>true</HasCalculationLinkbase>
</FilingSummary>