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

    <schemaVersion>X0508</schemaVersion>

    <documentType>4</documentType>

    <periodOfReport>2023-12-01</periodOfReport>

    <issuer>
        <issuerCik>0000352915</issuerCik>
        <issuerName>UNIVERSAL HEALTH SERVICES INC</issuerName>
        <issuerTradingSymbol>UHS</issuerTradingSymbol>
    </issuer>

    <reportingOwner>
        <reportingOwnerId>
            <rptOwnerCik>0001947699</rptOwnerCik>
            <rptOwnerName>Chen-Langenmayr Nina</rptOwnerName>
        </reportingOwnerId>
        <reportingOwnerAddress>
            <rptOwnerStreet1>211 N. 13TH STREET</rptOwnerStreet1>
            <rptOwnerStreet2>4TH FLOOR</rptOwnerStreet2>
            <rptOwnerCity>PHILADELPHIA</rptOwnerCity>
            <rptOwnerState>PA</rptOwnerState>
            <rptOwnerZipCode>19107</rptOwnerZipCode>
            <rptOwnerStateDescription></rptOwnerStateDescription>
        </reportingOwnerAddress>
        <reportingOwnerRelationship>
            <isDirector>1</isDirector>
        </reportingOwnerRelationship>
    </reportingOwner>

    <aff10b5One>0</aff10b5One>

    <nonDerivativeTable>
        <nonDerivativeTransaction>
            <securityTitle>
                <value>Class B Common Stock</value>
            </securityTitle>
            <transactionDate>
                <value>2023-12-01</value>
            </transactionDate>
            <transactionCoding>
                <transactionFormType>4</transactionFormType>
                <transactionCode>S</transactionCode>
                <equitySwapInvolved>0</equitySwapInvolved>
                <footnoteId id="F1"/>
            </transactionCoding>
            <transactionTimeliness></transactionTimeliness>
            <transactionAmounts>
                <transactionShares>
                    <value>1405</value>
                </transactionShares>
                <transactionPricePerShare>
                    <value>138.64</value>
                </transactionPricePerShare>
                <transactionAcquiredDisposedCode>
                    <value>D</value>
                </transactionAcquiredDisposedCode>
            </transactionAmounts>
            <postTransactionAmounts>
                <sharesOwnedFollowingTransaction>
                    <value>1488</value>
                </sharesOwnedFollowingTransaction>
            </postTransactionAmounts>
            <ownershipNature>
                <directOrIndirectOwnership>
                    <value>D</value>
                </directOrIndirectOwnership>
            </ownershipNature>
        </nonDerivativeTransaction>
        <nonDerivativeTransaction>
            <securityTitle>
                <value>Class B Common Stock</value>
            </securityTitle>
            <transactionDate>
                <value>2023-12-06</value>
            </transactionDate>
            <transactionCoding>
                <transactionFormType>4</transactionFormType>
                <transactionCode>P</transactionCode>
                <equitySwapInvolved>0</equitySwapInvolved>
                <footnoteId id="F2"/>
            </transactionCoding>
            <transactionTimeliness></transactionTimeliness>
            <transactionAmounts>
                <transactionShares>
                    <value>250</value>
                    <footnoteId id="F3"/>
                </transactionShares>
                <transactionPricePerShare>
                    <value>136.73</value>
                </transactionPricePerShare>
                <transactionAcquiredDisposedCode>
                    <value>A</value>
                </transactionAcquiredDisposedCode>
            </transactionAmounts>
            <postTransactionAmounts>
                <sharesOwnedFollowingTransaction>
                    <value>1738</value>
                </sharesOwnedFollowingTransaction>
            </postTransactionAmounts>
            <ownershipNature>
                <directOrIndirectOwnership>
                    <value>D</value>
                </directOrIndirectOwnership>
            </ownershipNature>
        </nonDerivativeTransaction>
    </nonDerivativeTable>

    <footnotes>
        <footnote id="F1">All shares were sold at the same price of $138.64.</footnote>
        <footnote id="F2">All shares were purchased at the same price of $136.73.</footnote>
        <footnote id="F3">The reporting person's purchase of 250 shares Class B Common Stock in her IRA at a price of $ 136.73 on December 6, 2023 reported herein was matchable under Section 16(b) of the Securities Exchange Act of 1934, to the extent of 250 shares, with the reporting person's sale of 1,405 shares of Class B Common Stock at a price of $138.64 per share on December 1, 2023. The reporting person has agreed to pay to the Company, $477.50, representing the full amount of the profit realized in connection with the short-swing transaction.</footnote>
    </footnotes>

    <ownerSignature>
        <signatureName>/s/ Nina Chen-Langenmayr</signatureName>
        <signatureDate>2023-12-19</signatureDate>
    </ownerSignature>
</ownershipDocument>
