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

    <schemaVersion>X0206</schemaVersion>

    <documentType>3</documentType>

    <periodOfReport>2016-03-30</periodOfReport>

    <noSecuritiesOwned>0</noSecuritiesOwned>

    <issuer>
        <issuerCik>0001597313</issuerCik>
        <issuerName>ViewRay, Inc.</issuerName>
        <issuerTradingSymbol>VRAY</issuerTradingSymbol>
    </issuer>

    <reportingOwner>
        <reportingOwnerId>
            <rptOwnerCik>0001637087</rptOwnerCik>
            <rptOwnerName>Chandler D. David</rptOwnerName>
        </reportingOwnerId>
        <reportingOwnerAddress>
            <rptOwnerStreet1>C/O VIEWRAY, INC.</rptOwnerStreet1>
            <rptOwnerStreet2>2 THERMO FISHER WAY</rptOwnerStreet2>
            <rptOwnerCity>OAKWOOD VILLAGE</rptOwnerCity>
            <rptOwnerState>OH</rptOwnerState>
            <rptOwnerZipCode>44146</rptOwnerZipCode>
            <rptOwnerStateDescription></rptOwnerStateDescription>
        </reportingOwnerAddress>
        <reportingOwnerRelationship>
            <isDirector>0</isDirector>
            <isOfficer>1</isOfficer>
            <isTenPercentOwner>0</isTenPercentOwner>
            <isOther>0</isOther>
            <officerTitle>Chief Financial Officer</officerTitle>
            <otherText></otherText>
        </reportingOwnerRelationship>
    </reportingOwner>

    <nonDerivativeTable></nonDerivativeTable>

    <derivativeTable>
        <derivativeHolding>
            <securityTitle>
                <value>Stock Option (right to buy)</value>
            </securityTitle>
            <conversionOrExercisePrice>
                <value>.68</value>
            </conversionOrExercisePrice>
            <exerciseDate>
                <footnoteId id="F1"/>
            </exerciseDate>
            <expirationDate>
                <value>2021-02-04</value>
            </expirationDate>
            <underlyingSecurity>
                <underlyingSecurityTitle>
                    <value>Common Stock</value>
                </underlyingSecurityTitle>
                <underlyingSecurityShares>
                    <value>128927</value>
                </underlyingSecurityShares>
            </underlyingSecurity>
            <ownershipNature>
                <directOrIndirectOwnership>
                    <value>D</value>
                </directOrIndirectOwnership>
            </ownershipNature>
        </derivativeHolding>
        <derivativeHolding>
            <securityTitle>
                <value>Stock Option (right to buy)</value>
            </securityTitle>
            <conversionOrExercisePrice>
                <value>.70</value>
            </conversionOrExercisePrice>
            <exerciseDate>
                <footnoteId id="F2"/>
            </exerciseDate>
            <expirationDate>
                <value>2022-03-01</value>
            </expirationDate>
            <underlyingSecurity>
                <underlyingSecurityTitle>
                    <value>Common Stock</value>
                </underlyingSecurityTitle>
                <underlyingSecurityShares>
                    <value>24371</value>
                </underlyingSecurityShares>
            </underlyingSecurity>
            <ownershipNature>
                <directOrIndirectOwnership>
                    <value>D</value>
                </directOrIndirectOwnership>
            </ownershipNature>
        </derivativeHolding>
        <derivativeHolding>
            <securityTitle>
                <value>Stock Option (right to buy)</value>
            </securityTitle>
            <conversionOrExercisePrice>
                <value>.75</value>
            </conversionOrExercisePrice>
            <exerciseDate>
                <footnoteId id="F3"/>
            </exerciseDate>
            <expirationDate>
                <value>2024-04-11</value>
            </expirationDate>
            <underlyingSecurity>
                <underlyingSecurityTitle>
                    <value>Common Stock</value>
                </underlyingSecurityTitle>
                <underlyingSecurityShares>
                    <value>37044</value>
                </underlyingSecurityShares>
            </underlyingSecurity>
            <ownershipNature>
                <directOrIndirectOwnership>
                    <value>D</value>
                </directOrIndirectOwnership>
            </ownershipNature>
        </derivativeHolding>
        <derivativeHolding>
            <securityTitle>
                <value>Stock Option (right to buy)</value>
            </securityTitle>
            <conversionOrExercisePrice>
                <value>.75</value>
            </conversionOrExercisePrice>
            <exerciseDate>
                <footnoteId id="F4"/>
            </exerciseDate>
            <expirationDate>
                <value>2024-04-11</value>
            </expirationDate>
            <underlyingSecurity>
                <underlyingSecurityTitle>
                    <value>Common Stock</value>
                </underlyingSecurityTitle>
                <underlyingSecurityShares>
                    <value>10335</value>
                </underlyingSecurityShares>
            </underlyingSecurity>
            <ownershipNature>
                <directOrIndirectOwnership>
                    <value>D</value>
                </directOrIndirectOwnership>
            </ownershipNature>
        </derivativeHolding>
        <derivativeHolding>
            <securityTitle>
                <value>Stock Option (right to buy)</value>
            </securityTitle>
            <conversionOrExercisePrice>
                <value>5</value>
            </conversionOrExercisePrice>
            <exerciseDate>
                <footnoteId id="F5"/>
            </exerciseDate>
            <expirationDate>
                <value>2025-07-23</value>
            </expirationDate>
            <underlyingSecurity>
                <underlyingSecurityTitle>
                    <value>Common Stock</value>
                </underlyingSecurityTitle>
                <underlyingSecurityShares>
                    <value>92661</value>
                </underlyingSecurityShares>
            </underlyingSecurity>
            <ownershipNature>
                <directOrIndirectOwnership>
                    <value>D</value>
                </directOrIndirectOwnership>
            </ownershipNature>
        </derivativeHolding>
    </derivativeTable>

    <footnotes>
        <footnote id="F1">25% of the shares subject to the option vest on January 1, 2011, and 1/48th of the total number of shares vest in thirty-six (36) monthly installments thereafter on the first calendar day of each month.</footnote>
        <footnote id="F2">The shares subject to the option vest in 48 monthly installments on each monthly anniversary of March 1, 2012, until such shares subject to the option have become fully vested and exercisable.</footnote>
        <footnote id="F3">The shares subject to the option vest in 48 monthly installments on the first calendar day of each month following May 13, 2013, until such shares subject to the option have become fully vested and exercisable.</footnote>
        <footnote id="F4">The shares subject to the option vest in 48 monthly installments on the first calendar day of each month following November 13, 2013, until such shares subject to the option have become fully vested and exercisable.</footnote>
        <footnote id="F5">The shares subject to the option vest in 48 monthly installments on each monthly anniversary of July 23, 2015, until such shares subject to the option have become fully vested and exercisable.</footnote>
    </footnotes>

    <ownerSignature>
        <signatureName>/s/ Wesley Mintu, Wesley Mintu, as Attorney-in-Fact for D. David Chandler</signatureName>
        <signatureDate>2016-03-30</signatureDate>
    </ownerSignature>
</ownershipDocument>
