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

    <schemaVersion>X0508</schemaVersion>

    <documentType>4</documentType>

    <periodOfReport>2024-11-16</periodOfReport>

    <issuer>
        <issuerCik>0000785956</issuerCik>
        <issuerName>J&amp;J SNACK FOODS CORP</issuerName>
        <issuerTradingSymbol>JJSF</issuerTradingSymbol>
    </issuer>

    <reportingOwner>
        <reportingOwnerId>
            <rptOwnerCik>0001220246</rptOwnerCik>
            <rptOwnerName>FACHNER DAN</rptOwnerName>
        </reportingOwnerId>
        <reportingOwnerAddress>
            <rptOwnerStreet1>C/O J&amp;J SNACK FOODS CORP.</rptOwnerStreet1>
            <rptOwnerStreet2>350 FELLOWSHIP ROAD</rptOwnerStreet2>
            <rptOwnerCity>MOUNT LAUREL</rptOwnerCity>
            <rptOwnerState>NJ</rptOwnerState>
            <rptOwnerZipCode>08054</rptOwnerZipCode>
            <rptOwnerStateDescription></rptOwnerStateDescription>
        </reportingOwnerAddress>
        <reportingOwnerRelationship>
            <isDirector>1</isDirector>
            <isOfficer>1</isOfficer>
            <officerTitle>Chairman, President &amp; CEO</officerTitle>
        </reportingOwnerRelationship>
    </reportingOwner>

    <aff10b5One>0</aff10b5One>

    <nonDerivativeTable>
        <nonDerivativeTransaction>
            <securityTitle>
                <value>Common stock, no par value</value>
            </securityTitle>
            <transactionDate>
                <value>2024-11-16</value>
            </transactionDate>
            <transactionCoding>
                <transactionFormType>4</transactionFormType>
                <transactionCode>F</transactionCode>
                <equitySwapInvolved>0</equitySwapInvolved>
            </transactionCoding>
            <transactionAmounts>
                <transactionShares>
                    <value>544</value>
                    <footnoteId id="F1"/>
                </transactionShares>
                <transactionPricePerShare>
                    <value>161.77</value>
                    <footnoteId id="F2"/>
                </transactionPricePerShare>
                <transactionAcquiredDisposedCode>
                    <value>D</value>
                </transactionAcquiredDisposedCode>
            </transactionAmounts>
            <postTransactionAmounts>
                <sharesOwnedFollowingTransaction>
                    <value>30649</value>
                    <footnoteId id="F3"/>
                </sharesOwnedFollowingTransaction>
            </postTransactionAmounts>
            <ownershipNature>
                <directOrIndirectOwnership>
                    <value>D</value>
                </directOrIndirectOwnership>
            </ownershipNature>
        </nonDerivativeTransaction>
        <nonDerivativeHolding>
            <securityTitle>
                <value>Common stock, no par value</value>
            </securityTitle>
            <postTransactionAmounts>
                <sharesOwnedFollowingTransaction>
                    <value>1753</value>
                </sharesOwnedFollowingTransaction>
            </postTransactionAmounts>
            <ownershipNature>
                <directOrIndirectOwnership>
                    <value>I</value>
                </directOrIndirectOwnership>
                <natureOfOwnership>
                    <value>See footnote</value>
                    <footnoteId id="F4"/>
                </natureOfOwnership>
            </ownershipNature>
        </nonDerivativeHolding>
        <nonDerivativeTransaction>
            <securityTitle>
                <value>Common stock, no par value</value>
            </securityTitle>
            <transactionDate>
                <value>2024-11-17</value>
            </transactionDate>
            <transactionCoding>
                <transactionFormType>4</transactionFormType>
                <transactionCode>F</transactionCode>
                <equitySwapInvolved>0</equitySwapInvolved>
            </transactionCoding>
            <transactionAmounts>
                <transactionShares>
                    <value>479</value>
                    <footnoteId id="F5"/>
                </transactionShares>
                <transactionPricePerShare>
                    <value>161.77</value>
                    <footnoteId id="F2"/>
                </transactionPricePerShare>
                <transactionAcquiredDisposedCode>
                    <value>D</value>
                </transactionAcquiredDisposedCode>
            </transactionAmounts>
            <postTransactionAmounts>
                <sharesOwnedFollowingTransaction>
                    <value>30170</value>
                    <footnoteId id="F3"/>
                </sharesOwnedFollowingTransaction>
            </postTransactionAmounts>
            <ownershipNature>
                <directOrIndirectOwnership>
                    <value>D</value>
                </directOrIndirectOwnership>
            </ownershipNature>
        </nonDerivativeTransaction>
        <nonDerivativeHolding>
            <securityTitle>
                <value>Common stock, no par value</value>
            </securityTitle>
            <postTransactionAmounts>
                <sharesOwnedFollowingTransaction>
                    <value>1753</value>
                </sharesOwnedFollowingTransaction>
            </postTransactionAmounts>
            <ownershipNature>
                <directOrIndirectOwnership>
                    <value>I</value>
                </directOrIndirectOwnership>
                <natureOfOwnership>
                    <value>See footnote</value>
                    <footnoteId id="F4"/>
                </natureOfOwnership>
            </ownershipNature>
        </nonDerivativeHolding>
    </nonDerivativeTable>

    <footnotes>
        <footnote id="F1">On November 16, 2022, 4,949 service share units were issued to the Reporting Person pursuant to a Service Share Unit Award with such shares vesting equally on the first, second and third anniversaries of the grant date.  This represents shares sold to cover taxes associated with the vesting of the second tranche.</footnote>
        <footnote id="F2">Represents the closing price on the last trading day immediately preceding the date of vesting, November 15, 2024.</footnote>
        <footnote id="F3">Includes 1,059 shares purchased by the Reporting Person through the J &amp; J Snack Foods Corp. 1996 Employee Stock Purchase Plan.</footnote>
        <footnote id="F4">Represents 1,753 shares held in the J &amp; J Snack Foods Corp. 401K Profit Sharing Plan as of November 8, 2024.</footnote>
        <footnote id="F5">On November 17, 2023, 4,454 service share units were issued to the Reporting Person pursuant to a  Restricted Stock Unit Award Agreement with such shares vesting equally on the first, second and third anniversaries of the grant date.  This represents shares sold to cover taxes associated with the vesting of the first tranche.</footnote>
    </footnotes>

    <ownerSignature>
        <signatureName>/s/ Michael A. Pollner, Attorney in Fact</signatureName>
        <signatureDate>2024-11-18</signatureDate>
    </ownerSignature>
</ownershipDocument>
