<?xml version="1.0" encoding="utf-8"?>
<xbrl
  xmlns="http://www.xbrl.org/2003/instance"
  xmlns:dei="http://xbrl.sec.gov/dei/2021"
  xmlns:link="http://www.xbrl.org/2003/linkbase"
  xmlns:xlink="http://www.w3.org/1999/xlink">
    <link:schemaRef xlink:href="ngm-20210630.xsd" xlink:type="simple"/>
    <context id="P01_01_2021To06_30_2021">
        <entity>
            <identifier scheme="http://www.sec.gov/CIK">0001426332</identifier>
        </entity>
        <period>
            <startDate>2021-01-01</startDate>
            <endDate>2021-06-30</endDate>
        </period>
    </context>
    <context id="PAsOn08_02_2021">
        <entity>
            <identifier scheme="http://www.sec.gov/CIK">0001426332</identifier>
        </entity>
        <period>
            <instant>2021-08-02</instant>
        </period>
    </context>
    <unit id="Unit_shares">
        <measure>shares</measure>
    </unit>
    <dei:EntityAddressStateOrProvince contextRef="P01_01_2021To06_30_2021" id="hidden28722093">CA</dei:EntityAddressStateOrProvince>
    <dei:AmendmentFlag contextRef="P01_01_2021To06_30_2021">true</dei:AmendmentFlag>
    <dei:DocumentFiscalPeriodFocus contextRef="P01_01_2021To06_30_2021">Q2</dei:DocumentFiscalPeriodFocus>
    <dei:EntityCentralIndexKey contextRef="P01_01_2021To06_30_2021">0001426332</dei:EntityCentralIndexKey>
    <dei:CurrentFiscalYearEndDate contextRef="P01_01_2021To06_30_2021">--12-31</dei:CurrentFiscalYearEndDate>
    <dei:DocumentType contextRef="P01_01_2021To06_30_2021">10-Q/A</dei:DocumentType>
    <dei:DocumentQuarterlyReport contextRef="P01_01_2021To06_30_2021">true</dei:DocumentQuarterlyReport>
    <dei:DocumentPeriodEndDate contextRef="P01_01_2021To06_30_2021">2021-06-30</dei:DocumentPeriodEndDate>
    <dei:DocumentFiscalYearFocus contextRef="P01_01_2021To06_30_2021">2021</dei:DocumentFiscalYearFocus>
    <dei:DocumentTransitionReport contextRef="P01_01_2021To06_30_2021">false</dei:DocumentTransitionReport>
    <dei:EntityFileNumber contextRef="P01_01_2021To06_30_2021">001-38853</dei:EntityFileNumber>
    <dei:EntityRegistrantName contextRef="P01_01_2021To06_30_2021">NGM BIOPHARMACEUTICALS, INC.</dei:EntityRegistrantName>
    <dei:EntityIncorporationStateCountryCode contextRef="P01_01_2021To06_30_2021">DE</dei:EntityIncorporationStateCountryCode>
    <dei:EntityTaxIdentificationNumber contextRef="P01_01_2021To06_30_2021">26-1679911</dei:EntityTaxIdentificationNumber>
    <dei:EntityAddressAddressLine1 contextRef="P01_01_2021To06_30_2021">333 Oyster Point Boulevard</dei:EntityAddressAddressLine1>
    <dei:EntityAddressCityOrTown contextRef="P01_01_2021To06_30_2021">South San Francisco</dei:EntityAddressCityOrTown>
    <dei:EntityAddressPostalZipCode contextRef="P01_01_2021To06_30_2021">94080</dei:EntityAddressPostalZipCode>
    <dei:CityAreaCode contextRef="P01_01_2021To06_30_2021">650</dei:CityAreaCode>
    <dei:LocalPhoneNumber contextRef="P01_01_2021To06_30_2021">243-5555</dei:LocalPhoneNumber>
    <dei:Security12bTitle contextRef="P01_01_2021To06_30_2021">Common Stock, par value $0.001 per share</dei:Security12bTitle>
    <dei:TradingSymbol contextRef="P01_01_2021To06_30_2021">NGM</dei:TradingSymbol>
    <dei:SecurityExchangeName contextRef="P01_01_2021To06_30_2021">NASDAQ</dei:SecurityExchangeName>
    <dei:EntityCurrentReportingStatus contextRef="P01_01_2021To06_30_2021">Yes</dei:EntityCurrentReportingStatus>
    <dei:EntityInteractiveDataCurrent contextRef="P01_01_2021To06_30_2021">Yes</dei:EntityInteractiveDataCurrent>
    <dei:EntityFilerCategory contextRef="P01_01_2021To06_30_2021">Accelerated Filer</dei:EntityFilerCategory>
    <dei:EntitySmallBusiness contextRef="P01_01_2021To06_30_2021">false</dei:EntitySmallBusiness>
    <dei:EntityEmergingGrowthCompany contextRef="P01_01_2021To06_30_2021">true</dei:EntityEmergingGrowthCompany>
    <dei:EntityExTransitionPeriod contextRef="P01_01_2021To06_30_2021">false</dei:EntityExTransitionPeriod>
    <dei:EntityShellCompany contextRef="P01_01_2021To06_30_2021">false</dei:EntityShellCompany>
    <dei:EntityCommonStockSharesOutstanding
      contextRef="PAsOn08_02_2021"
      decimals="INF"
      unitRef="Unit_shares">77338144</dei:EntityCommonStockSharesOutstanding>
    <dei:AmendmentDescription contextRef="P01_01_2021To06_30_2021">EXPLANATORY NOTE  We are filing this Amendment No.&#160;1 to Quarterly Report on Form 10-Q/A (this &#x201c;Amendment&#x201d;) to amend our Quarterly Report on Form 10-Q for the quarterly period ended June&#160;30, 2021, as filed with the Securities and Exchange Commission (the &#x201c;SEC&#x201d;) on August&#160;5, 2021 (the &#x201c;10-Q&#x201d;). This Amendment is being filed solely to refile the certifications of our principal executive officer and principal financial officer as exhibits to this Amendment as required pursuant to Rules 13a-14(a) and 15d-14(a) under the Securities and Exchange Act of 1934.  No attempt has been made in this Amendment to otherwise modify or update the other disclosures presented in the 10-Q. This Amendment does not reflect events occurring after the filing of the original 10-Q (i.e., those events occurring after August&#160;5, 2021) or modify or update those disclosures that may be affected by subsequent events. Such subsequent matters are addressed in subsequent reports filed with the SEC. Accordingly, this Amendment should be read in conjunction with the 10-Q and our other filings with the SEC. </dei:AmendmentDescription>
</xbrl>
