<?xml version="1.0" encoding="utf-8"?>
<xbrl
  xmlns="http://www.xbrl.org/2003/instance"
  xmlns:dei="http://xbrl.sec.gov/dei/2021"
  xmlns:iso4217="http://www.xbrl.org/2003/iso4217"
  xmlns:link="http://www.xbrl.org/2003/linkbase"
  xmlns:xlink="http://www.w3.org/1999/xlink">
    <link:schemaRef xlink:href="ngm-20201231.xsd" xlink:type="simple"/>
    <context id="P01_01_2020To12_31_2020">
        <entity>
            <identifier scheme="http://www.sec.gov/CIK">0001426332</identifier>
        </entity>
        <period>
            <startDate>2020-01-01</startDate>
            <endDate>2020-12-31</endDate>
        </period>
    </context>
    <context id="PAsOn03_10_2021">
        <entity>
            <identifier scheme="http://www.sec.gov/CIK">0001426332</identifier>
        </entity>
        <period>
            <instant>2021-03-10</instant>
        </period>
    </context>
    <context id="PAsOn06_30_2020">
        <entity>
            <identifier scheme="http://www.sec.gov/CIK">0001426332</identifier>
        </entity>
        <period>
            <instant>2020-06-30</instant>
        </period>
    </context>
    <unit id="Unit_shares">
        <measure>shares</measure>
    </unit>
    <unit id="Unit_USD">
        <measure>iso4217:USD</measure>
    </unit>
    <dei:EntityCurrentReportingStatus contextRef="P01_01_2020To12_31_2020" id="hidden28931541">Yes</dei:EntityCurrentReportingStatus>
    <dei:EntityInteractiveDataCurrent contextRef="P01_01_2020To12_31_2020" id="hidden28931564">Yes</dei:EntityInteractiveDataCurrent>
    <dei:AmendmentFlag contextRef="P01_01_2020To12_31_2020">true</dei:AmendmentFlag>
    <dei:DocumentFiscalPeriodFocus contextRef="P01_01_2020To12_31_2020">FY</dei:DocumentFiscalPeriodFocus>
    <dei:EntityCentralIndexKey contextRef="P01_01_2020To12_31_2020">0001426332</dei:EntityCentralIndexKey>
    <dei:CurrentFiscalYearEndDate contextRef="P01_01_2020To12_31_2020">--12-31</dei:CurrentFiscalYearEndDate>
    <dei:EntityWellKnownSeasonedIssuer contextRef="P01_01_2020To12_31_2020" id="hidden28931567">No</dei:EntityWellKnownSeasonedIssuer>
    <dei:EntityVoluntaryFilers contextRef="P01_01_2020To12_31_2020" id="hidden28931569">No</dei:EntityVoluntaryFilers>
    <dei:DocumentType contextRef="P01_01_2020To12_31_2020">10-K/A</dei:DocumentType>
    <dei:DocumentAnnualReport contextRef="P01_01_2020To12_31_2020">true</dei:DocumentAnnualReport>
    <dei:DocumentPeriodEndDate contextRef="P01_01_2020To12_31_2020">2020-12-31</dei:DocumentPeriodEndDate>
    <dei:DocumentFiscalYearFocus contextRef="P01_01_2020To12_31_2020">2020</dei:DocumentFiscalYearFocus>
    <dei:DocumentTransitionReport contextRef="P01_01_2020To12_31_2020">false</dei:DocumentTransitionReport>
    <dei:EntityFileNumber contextRef="P01_01_2020To12_31_2020">001-38853</dei:EntityFileNumber>
    <dei:EntityRegistrantName contextRef="P01_01_2020To12_31_2020">NGM BIOPHARMACEUTICALS, INC.</dei:EntityRegistrantName>
    <dei:EntityIncorporationStateCountryCode contextRef="P01_01_2020To12_31_2020">DE</dei:EntityIncorporationStateCountryCode>
    <dei:EntityTaxIdentificationNumber contextRef="P01_01_2020To12_31_2020">26-1679911</dei:EntityTaxIdentificationNumber>
    <dei:EntityAddressAddressLine1 contextRef="P01_01_2020To12_31_2020">333 Oyster Point Boulevard</dei:EntityAddressAddressLine1>
    <dei:EntityAddressCityOrTown contextRef="P01_01_2020To12_31_2020">South San Francisco</dei:EntityAddressCityOrTown>
    <dei:EntityAddressStateOrProvince contextRef="P01_01_2020To12_31_2020">CA</dei:EntityAddressStateOrProvince>
    <dei:EntityAddressPostalZipCode contextRef="P01_01_2020To12_31_2020">94080</dei:EntityAddressPostalZipCode>
    <dei:CityAreaCode contextRef="P01_01_2020To12_31_2020">650</dei:CityAreaCode>
    <dei:LocalPhoneNumber contextRef="P01_01_2020To12_31_2020">243-5555</dei:LocalPhoneNumber>
    <dei:Security12bTitle contextRef="P01_01_2020To12_31_2020">Common Stock, par value $0.001 per share</dei:Security12bTitle>
    <dei:TradingSymbol contextRef="P01_01_2020To12_31_2020">NGM</dei:TradingSymbol>
    <dei:SecurityExchangeName contextRef="P01_01_2020To12_31_2020">NASDAQ</dei:SecurityExchangeName>
    <dei:EntityFilerCategory contextRef="P01_01_2020To12_31_2020">Accelerated Filer</dei:EntityFilerCategory>
    <dei:EntitySmallBusiness contextRef="P01_01_2020To12_31_2020">false</dei:EntitySmallBusiness>
    <dei:EntityEmergingGrowthCompany contextRef="P01_01_2020To12_31_2020">true</dei:EntityEmergingGrowthCompany>
    <dei:EntityExTransitionPeriod contextRef="P01_01_2020To12_31_2020">false</dei:EntityExTransitionPeriod>
    <dei:IcfrAuditorAttestationFlag contextRef="P01_01_2020To12_31_2020">false</dei:IcfrAuditorAttestationFlag>
    <dei:EntityShellCompany contextRef="P01_01_2020To12_31_2020">false</dei:EntityShellCompany>
    <dei:EntityPublicFloat
      contextRef="PAsOn06_30_2020"
      decimals="-6"
      unitRef="Unit_USD">457000000</dei:EntityPublicFloat>
    <dei:EntityCommonStockSharesOutstanding
      contextRef="PAsOn03_10_2021"
      decimals="INF"
      unitRef="Unit_shares">76692401</dei:EntityCommonStockSharesOutstanding>
    <dei:DocumentsIncorporatedByReferenceTextBlock contextRef="P01_01_2020To12_31_2020">Portions of the registrant&#x2019;s definitive Proxy Statement for the 2021 Annual Meeting of Stockholders to be filed with the U.S. Securities and Exchange Commission pursuant to Regulation 14A not later than 120 days after the end of the fiscal year covered by this Annual Report on Form &lt;div style="white-space: nowrap; letter-spacing: 0px; top: 0px;;display:inline;"&gt;10-K&lt;/div&gt; are incorporated by reference in Part III, Items &lt;div style="white-space: nowrap; letter-spacing: 0px; top: 0px;;display:inline;"&gt;10-14&lt;/div&gt; of this Annual Report on Form &lt;div style="white-space: nowrap; letter-spacing: 0px; top: 0px;;display:inline;"&gt;10-K.&lt;/div&gt;</dei:DocumentsIncorporatedByReferenceTextBlock>
    <dei:AmendmentDescription contextRef="P01_01_2020To12_31_2020">  EXPLANATORY NOTE  We are filing this Amendment No.&#160;1 to Annual Report on Form 10-K/A (this &#x201c;Amendment&#x201d;) to amend our Annual Report on Form 10-K for the fiscal year ended December&#160;31, 2020, as filed with the Securities and Exchange Commission (the &#x201c;SEC&#x201d;) on March&#160;15, 2021 (the &#x201c;10-K&#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-K. This Amendment does not reflect events occurring after the filing of the original 10-K (i.e., those events occurring after March&#160;15, 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-K and our other filings with the SEC.   </dei:AmendmentDescription>
</xbrl>
