<?xml version="1.0" encoding="utf-8"?>
<xbrl
  xml:lang="en-US"
  xmlns="http://www.xbrl.org/2003/instance"
  xmlns:dei="http://xbrl.sec.gov/dei/2025"
  xmlns:ffd="http://xbrl.sec.gov/ffd/2025"
  xmlns:iso4217="http://www.xbrl.org/2003/iso4217"
  xmlns:link="http://www.xbrl.org/2003/linkbase"
  xmlns:xbrldi="http://xbrl.org/2006/xbrldi"
  xmlns:xlink="http://www.w3.org/1999/xlink">
    <link:schemaRef
      xlink:href="https://xbrl.sec.gov/ffd/2025/ffd-2025.xsd"
      xlink:type="simple"/>
    <context id="c-1">
        <entity>
            <identifier scheme="http://www.sec.gov/CIK">0001501697</identifier>
            <segment>
                <xbrldi:typedMember dimension="ffd:OfferingAxis">
                    <dei:lineNo>1</dei:lineNo>
                </xbrldi:typedMember>
            </segment>
        </entity>
        <period>
            <startDate>2026-03-17</startDate>
            <endDate>2026-03-17</endDate>
        </period>
    </context>
    <context id="c-2">
        <entity>
            <identifier scheme="http://www.sec.gov/CIK">0001501697</identifier>
            <segment>
                <xbrldi:typedMember dimension="ffd:OfferingAxis">
                    <dei:lineNo>3</dei:lineNo>
                </xbrldi:typedMember>
            </segment>
        </entity>
        <period>
            <startDate>2026-03-17</startDate>
            <endDate>2026-03-17</endDate>
        </period>
    </context>
    <context id="c-3">
        <entity>
            <identifier scheme="http://www.sec.gov/CIK">0001501697</identifier>
            <segment>
                <xbrldi:typedMember dimension="ffd:OfferingAxis">
                    <dei:lineNo>2</dei:lineNo>
                </xbrldi:typedMember>
            </segment>
        </entity>
        <period>
            <startDate>2026-03-17</startDate>
            <endDate>2026-03-17</endDate>
        </period>
    </context>
    <context id="c-4">
        <entity>
            <identifier scheme="http://www.sec.gov/CIK">0001501697</identifier>
        </entity>
        <period>
            <startDate>2026-03-17</startDate>
            <endDate>2026-03-17</endDate>
        </period>
    </context>
    <unit id="shares">
        <measure>shares</measure>
    </unit>
    <unit id="usd">
        <measure>iso4217:USD</measure>
    </unit>
    <unit id="number">
        <measure>pure</measure>
    </unit>
    <dei:EntityCentralIndexKey contextRef="c-4" id="f-35">0001501697</dei:EntityCentralIndexKey>
    <dei:EntityRegistrantName contextRef="c-4" id="f-36">X4 Pharmaceuticals, Inc.</dei:EntityRegistrantName>
    <ffd:FormTp contextRef="c-4" id="f-37">S-8</ffd:FormTp>
    <ffd:SubmissnTp contextRef="c-4" id="f-38">S-8</ffd:SubmissnTp>
    <ffd:FeeExhibitTp contextRef="c-4" id="f-39">EX-FILING FEES</ffd:FeeExhibitTp>
    <ffd:OffsetTableNa contextRef="c-4" id="f-40">N/A</ffd:OffsetTableNa>
    <ffd:PrevslyPdFlg contextRef="c-1" id="f-1">false</ffd:PrevslyPdFlg>
    <ffd:OfferingSctyTp contextRef="c-1" id="f-2">Equity</ffd:OfferingSctyTp>
    <ffd:OfferingSctyTitl contextRef="c-1" id="f-3">Common Stock, $0.001 par value per share ("Common Stock") to be issued under the X4 Pharmaceuticals, Inc. Amended and Restated 2017 Equity Incentive Plan (the "2017 Plan")</ffd:OfferingSctyTitl>
    <ffd:FeesOthrRuleFlg contextRef="c-1" id="f-4">true</ffd:FeesOthrRuleFlg>
    <ffd:AmtSctiesRegd contextRef="c-1" decimals="0" id="f-5" unitRef="shares">3636276</ffd:AmtSctiesRegd>
    <ffd:MaxOfferingPricPerScty contextRef="c-1" decimals="2" id="f-6" unitRef="usd">4.00</ffd:MaxOfferingPricPerScty>
    <ffd:MaxAggtOfferingPric contextRef="c-1" decimals="0" id="f-7" unitRef="usd">14545104</ffd:MaxAggtOfferingPric>
    <ffd:FeeRate contextRef="c-1" decimals="7" id="f-8" unitRef="number">0.0001381</ffd:FeeRate>
    <ffd:FeeAmt contextRef="c-1" decimals="2" id="f-9" unitRef="usd">2008.68</ffd:FeeAmt>
    <ffd:OfferingSctyTp contextRef="c-2" id="f-10">Equity</ffd:OfferingSctyTp>
    <ffd:PrevslyPdFlg contextRef="c-2" id="f-11">false</ffd:PrevslyPdFlg>
    <ffd:OfferingSctyTitl contextRef="c-2" id="f-12">Common Stock, $0.001 par value per share, X4 Pharmaceuticals Inc. 2017 Equity Incentive Plan</ffd:OfferingSctyTitl>
    <ffd:FeesOthrRuleFlg contextRef="c-2" id="f-13">true</ffd:FeesOthrRuleFlg>
    <ffd:AmtSctiesRegd contextRef="c-2" decimals="0" id="f-14" unitRef="shares">1060000</ffd:AmtSctiesRegd>
    <ffd:MaxOfferingPricPerScty contextRef="c-2" decimals="2" id="f-15" unitRef="usd">4.07</ffd:MaxOfferingPricPerScty>
    <ffd:MaxAggtOfferingPric contextRef="c-2" decimals="0" id="f-16" unitRef="usd">4314200</ffd:MaxAggtOfferingPric>
    <ffd:FeeRate contextRef="c-2" decimals="7" id="f-17" unitRef="number">0.0001381</ffd:FeeRate>
    <ffd:FeeAmt contextRef="c-2" decimals="2" id="f-18" unitRef="usd">595.79</ffd:FeeAmt>
    <ffd:PrevslyPdFlg contextRef="c-3" id="f-19">false</ffd:PrevslyPdFlg>
    <ffd:OfferingSctyTp contextRef="c-3" id="f-20">Equity</ffd:OfferingSctyTp>
    <ffd:OfferingSctyTitl contextRef="c-3" id="f-21">Common Stock, $0.001 par value per share, X4 Pharmaceuticals Inc. 2017 Equity Incentive Plan</ffd:OfferingSctyTitl>
    <ffd:FeesOthrRuleFlg contextRef="c-3" id="f-22">true</ffd:FeesOthrRuleFlg>
    <ffd:AmtSctiesRegd contextRef="c-3" decimals="0" id="f-23" unitRef="shares">440000</ffd:AmtSctiesRegd>
    <ffd:MaxOfferingPricPerScty contextRef="c-3" decimals="2" id="f-24" unitRef="usd">4.00</ffd:MaxOfferingPricPerScty>
    <ffd:MaxAggtOfferingPric contextRef="c-3" decimals="0" id="f-25" unitRef="usd">1760000</ffd:MaxAggtOfferingPric>
    <ffd:FeeRate contextRef="c-3" decimals="7" id="f-26" unitRef="number">0.0001381</ffd:FeeRate>
    <ffd:FeeAmt contextRef="c-3" decimals="2" id="f-27" unitRef="usd">243.06</ffd:FeeAmt>
    <ffd:TtlOfferingAmt contextRef="c-4" decimals="0" id="f-28" unitRef="usd">20619304</ffd:TtlOfferingAmt>
    <ffd:TtlFeeAmt contextRef="c-4" decimals="2" id="f-29" unitRef="usd">2847.53</ffd:TtlFeeAmt>
    <ffd:TtlOffsetAmt contextRef="c-4" decimals="2" id="f-30" unitRef="usd">0.00</ffd:TtlOffsetAmt>
    <ffd:NetFeeAmt contextRef="c-4" decimals="2" id="f-31" unitRef="usd">2847.53</ffd:NetFeeAmt>
    <ffd:OfferingNote contextRef="c-1" id="f-32">&lt;div style="padding-left:13.5pt;text-indent:-13.5pt"&gt;&lt;span style="color:#000000;font-family:'Times New Roman',serif;font-size:9pt;font-weight:400;line-height:112%"&gt;(1) Pursuant to Rule 416 of the Securities Act of 1933, as amended (the &#x201c;&lt;/span&gt;&lt;span style="color:#000000;font-family:'Times New Roman',serif;font-size:9pt;font-style:italic;font-weight:700;line-height:112%"&gt;Securities Act&lt;/span&gt;&lt;span style="color:#000000;font-family:'Times New Roman',serif;font-size:9pt;font-weight:400;line-height:112%"&gt;&#x201d;), this Registration Statement shall also cover any additional shares of the Registrant&#x2019;s Common Stock, that become issuable under the 2017 Plan by reason of any stock dividend, stock split, recapitalization or other similar transaction effected without receipt of consideration that increases the number of the Registrant&#x2019;s outstanding shares of Common Stock.&lt;/span&gt;&lt;/div&gt;&lt;div style="padding-left:13.5pt"&gt;&lt;span&gt;&lt;br/&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="padding-left:13.5pt;text-indent:-13.5pt"&gt;&lt;span style="color:#000000;font-family:'Times New Roman',serif;font-size:9pt;font-weight:400;line-height:112%"&gt;(2) &lt;/span&gt;&lt;span style="color:#000000;font-family:'Arial',sans-serif;font-size:9pt;font-weight:400;line-height:112%"&gt;C&lt;/span&gt;&lt;span style="color:#000000;font-family:'Times New Roman',serif;font-size:9pt;font-weight:400;line-height:112%"&gt;onsists of 3,636,276 shares of Common Stock that were automatically added to the shares authorized for issuance under the 2017 Plan on January 1, 2026, pursuant to an &#x201c;evergreen&#x201d; provision contained in the 2017 Plan. Pursuant to such &#x201c;evergreen&#x201d; provision contained in the 2017 Plan, on January 1 of each year from 2021 until (and including) 2027, the number of shares authorized for issuance under the 2017 Plan is automatically increased by a number equal to the amount equal to the least of (1) 4% of the total number of shares of Common Stock outstanding on December 31st of the preceding calendar year, or (2) a number of shares determined by the Registrant&#x2019;s Board of Directors. The proposed maximum offering price per unit is estimated &lt;/span&gt;&lt;/div&gt;&lt;div style="padding-left:13.5pt"&gt;&lt;span style="color:#000000;font-family:'Times New Roman',serif;font-size:9pt;font-weight:400;line-height:112%"&gt;in accordance with Rule 457(a) and Rule 457(h) solely for the purpose of calculating the registration fee pursuant to Rule 457(h) under the Securities Act and is based upon the exercise price of the options, which is $4.00 per share of Common Stock.&lt;/span&gt;&lt;/div&gt;</ffd:OfferingNote>
    <ffd:OfferingNote contextRef="c-2" id="f-33">Consists of 1,060,000 shares of Common Stock that are to be approved for issuance under the 2017 Plan by the Registrant&#x2019;s shareholders at the Registrant&#x2019;s 2026 Annual Meeting of Stockholders. The proposed maximum offering price per unit is estimated in accordance with Rule 457(c) and Rule 457(h) solely for the purpose of calculating the registration fee. The offering price per share and the aggregate offering price are calculated based on the average of the high and low sale prices per share of the Common Stock as reported on The Nasdaq Capital Market on March 12, 2026&lt;span style="color:#000000;font-family:'Times New Roman',serif;font-size:10pt;font-weight:400;line-height:112%"&gt;.&lt;/span&gt;</ffd:OfferingNote>
    <ffd:OfferingNote contextRef="c-3" id="f-34">Consists of 440,000 shares of Common Stock subject to previously granted stock options, which shares are to be approved for issuance under the 2017 Plan by the Registrant&#x2019;s shareholders at the Registrant&#x2019;s 2026 Annual Meeting of Stockholders. The proposed maximum offering price per unit is estimated in accordance with Rule 457(a) and Rule 457(h) solely for the purpose of calculating the registration fee pursuant to Rule 457(h) under the Securities Act and is based upon the exercise price of the options, which is $4.00 per share&lt;span style="color:#000000;font-family:'Times New Roman',serif;font-size:10pt;font-weight:400;line-height:112%"&gt;.&lt;/span&gt;</ffd:OfferingNote>
</xbrl>
