<?xml version="1.0"?>
<ownershipDocument>

    <schemaVersion>X0508</schemaVersion>

    <documentType>4</documentType>

    <periodOfReport>2024-08-01</periodOfReport>

    <issuer>
        <issuerCik>0001035983</issuerCik>
        <issuerName>COMFORT SYSTEMS USA INC</issuerName>
        <issuerTradingSymbol>FIX</issuerTradingSymbol>
    </issuer>

    <reportingOwner>
        <reportingOwnerId>
            <rptOwnerCik>0001693758</rptOwnerCik>
            <rptOwnerName>Kapoor Gaurav</rptOwnerName>
        </reportingOwnerId>
        <reportingOwnerAddress>
            <rptOwnerStreet1>675 BERING DRIVE, SUITE 400</rptOwnerStreet1>
            <rptOwnerStreet2></rptOwnerStreet2>
            <rptOwnerCity>HOUSTON</rptOwnerCity>
            <rptOwnerState>TX</rptOwnerState>
            <rptOwnerZipCode>77057</rptOwnerZipCode>
            <rptOwnerStateDescription></rptOwnerStateDescription>
        </reportingOwnerAddress>
        <reportingOwnerRelationship>
            <isDirector>true</isDirector>
            <isOfficer>false</isOfficer>
            <isTenPercentOwner>false</isTenPercentOwner>
            <isOther>false</isOther>
            <officerTitle></officerTitle>
            <otherText></otherText>
        </reportingOwnerRelationship>
    </reportingOwner>

    <aff10b5One>0</aff10b5One>

    <nonDerivativeTable>
        <nonDerivativeTransaction>
            <securityTitle>
                <value>Common Stock</value>
            </securityTitle>
            <transactionDate>
                <value>2024-08-01</value>
            </transactionDate>
            <transactionCoding>
                <transactionFormType>4</transactionFormType>
                <transactionCode>A</transactionCode>
                <equitySwapInvolved>0</equitySwapInvolved>
            </transactionCoding>
            <transactionAmounts>
                <transactionShares>
                    <value>385</value>
                </transactionShares>
                <transactionPricePerShare>
                    <value>0</value>
                    <footnoteId id="F1"/>
                </transactionPricePerShare>
                <transactionAcquiredDisposedCode>
                    <value>A</value>
                </transactionAcquiredDisposedCode>
            </transactionAmounts>
            <postTransactionAmounts>
                <sharesOwnedFollowingTransaction>
                    <value>385</value>
                </sharesOwnedFollowingTransaction>
            </postTransactionAmounts>
            <ownershipNature>
                <directOrIndirectOwnership>
                    <value>I</value>
                </directOrIndirectOwnership>
                <natureOfOwnership>
                    <value>By Trust</value>
                    <footnoteId id="F2"/>
                </natureOfOwnership>
            </ownershipNature>
        </nonDerivativeTransaction>
    </nonDerivativeTable>

    <derivativeTable></derivativeTable>

    <footnotes>
        <footnote id="F1">Shares granted pursuant to the 2017 Omnibus Incentive Plan as approved by stockholders on May 23, 2017. Non-employee directors are given an annual grant of Comfort Systems USA Common Stock following election or reelection at the Company's annual stockholders' meeting. Mr. Kapoor's term of service commenced August 1, 2024, and Mr. Kapoor received a pro rated grant. This grant is equal to $126,684.93, as rounded down to the nearest whole share, based on the average of the high and low price of the Company's Common Stock on August 1, 2024, the date the pro rated grant was effective in accordance with Mr. Kapoor's appointment date.</footnote>
        <footnote id="F2">Held by Kapoor Family Trust, dated August 20, 2023, for which the Reporting Person and his spouse are trustees.</footnote>
    </footnotes>

    <ownerSignature>
        <signatureName>/s/ Rachel R. Eslicker, Attorney-in-Fact</signatureName>
        <signatureDate>2024-08-02</signatureDate>
    </ownerSignature>
</ownershipDocument>
