<?xml version="1.0" encoding="utf-8"?>
<xbrl
  xmlns="http://www.xbrl.org/2003/instance"
  xmlns:dei="http://xbrl.sec.gov/dei/2022"
  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-20221231.xsd" xlink:type="simple"/>
    <context id="P01_01_2022To12_31_2022">
        <entity>
            <identifier scheme="http://www.sec.gov/CIK">0001426332</identifier>
        </entity>
        <period>
            <startDate>2022-01-01</startDate>
            <endDate>2022-12-31</endDate>
        </period>
    </context>
    <context id="PAsOn02_22_2023">
        <entity>
            <identifier scheme="http://www.sec.gov/CIK">0001426332</identifier>
        </entity>
        <period>
            <instant>2023-02-22</instant>
        </period>
    </context>
    <context id="PAsOn06_30_2022">
        <entity>
            <identifier scheme="http://www.sec.gov/CIK">0001426332</identifier>
        </entity>
        <period>
            <instant>2022-06-30</instant>
        </period>
    </context>
    <unit id="Unit_shares">
        <measure>shares</measure>
    </unit>
    <unit id="Unit_USD">
        <measure>iso4217:USD</measure>
    </unit>
    <dei:AmendmentFlag contextRef="P01_01_2022To12_31_2022">true</dei:AmendmentFlag>
    <dei:DocumentFiscalPeriodFocus contextRef="P01_01_2022To12_31_2022">FY</dei:DocumentFiscalPeriodFocus>
    <dei:EntityCentralIndexKey contextRef="P01_01_2022To12_31_2022">0001426332</dei:EntityCentralIndexKey>
    <dei:DocumentType contextRef="P01_01_2022To12_31_2022">10-K/A</dei:DocumentType>
    <dei:DocumentAnnualReport contextRef="P01_01_2022To12_31_2022">true</dei:DocumentAnnualReport>
    <dei:DocumentPeriodEndDate contextRef="P01_01_2022To12_31_2022">2022-12-31</dei:DocumentPeriodEndDate>
    <dei:CurrentFiscalYearEndDate contextRef="P01_01_2022To12_31_2022">--12-31</dei:CurrentFiscalYearEndDate>
    <dei:DocumentFiscalYearFocus contextRef="P01_01_2022To12_31_2022">2022</dei:DocumentFiscalYearFocus>
    <dei:DocumentTransitionReport contextRef="P01_01_2022To12_31_2022">false</dei:DocumentTransitionReport>
    <dei:EntityFileNumber contextRef="P01_01_2022To12_31_2022">001-38853</dei:EntityFileNumber>
    <dei:EntityRegistrantName contextRef="P01_01_2022To12_31_2022">NGM BIOPHARMACEUTICALS, INC.</dei:EntityRegistrantName>
    <dei:EntityIncorporationStateCountryCode contextRef="P01_01_2022To12_31_2022">DE</dei:EntityIncorporationStateCountryCode>
    <dei:EntityTaxIdentificationNumber contextRef="P01_01_2022To12_31_2022">26-1679911</dei:EntityTaxIdentificationNumber>
    <dei:EntityAddressAddressLine1 contextRef="P01_01_2022To12_31_2022">333 Oyster Point Boulevard</dei:EntityAddressAddressLine1>
    <dei:EntityAddressCityOrTown contextRef="P01_01_2022To12_31_2022">South San Francisco</dei:EntityAddressCityOrTown>
    <dei:EntityAddressStateOrProvince contextRef="P01_01_2022To12_31_2022">CA</dei:EntityAddressStateOrProvince>
    <dei:EntityAddressPostalZipCode contextRef="P01_01_2022To12_31_2022">94080</dei:EntityAddressPostalZipCode>
    <dei:CityAreaCode contextRef="P01_01_2022To12_31_2022">650</dei:CityAreaCode>
    <dei:LocalPhoneNumber contextRef="P01_01_2022To12_31_2022">243-5555</dei:LocalPhoneNumber>
    <dei:Security12bTitle contextRef="P01_01_2022To12_31_2022">Common Stock, par value $0.001 per share</dei:Security12bTitle>
    <dei:TradingSymbol contextRef="P01_01_2022To12_31_2022">NGM</dei:TradingSymbol>
    <dei:SecurityExchangeName contextRef="P01_01_2022To12_31_2022">NASDAQ</dei:SecurityExchangeName>
    <dei:EntityWellKnownSeasonedIssuer contextRef="P01_01_2022To12_31_2022">Yes</dei:EntityWellKnownSeasonedIssuer>
    <dei:EntityVoluntaryFilers contextRef="P01_01_2022To12_31_2022">No</dei:EntityVoluntaryFilers>
    <dei:EntityCurrentReportingStatus contextRef="P01_01_2022To12_31_2022">Yes</dei:EntityCurrentReportingStatus>
    <dei:EntityInteractiveDataCurrent contextRef="P01_01_2022To12_31_2022">Yes</dei:EntityInteractiveDataCurrent>
    <dei:EntityFilerCategory contextRef="P01_01_2022To12_31_2022">Large Accelerated Filer</dei:EntityFilerCategory>
    <dei:EntitySmallBusiness contextRef="P01_01_2022To12_31_2022">false</dei:EntitySmallBusiness>
    <dei:EntityEmergingGrowthCompany contextRef="P01_01_2022To12_31_2022">false</dei:EntityEmergingGrowthCompany>
    <dei:IcfrAuditorAttestationFlag contextRef="P01_01_2022To12_31_2022">true</dei:IcfrAuditorAttestationFlag>
    <dei:EntityShellCompany contextRef="P01_01_2022To12_31_2022">false</dei:EntityShellCompany>
    <dei:EntityPublicFloat
      contextRef="PAsOn06_30_2022"
      decimals="-6"
      unitRef="Unit_USD">699000000</dei:EntityPublicFloat>
    <dei:EntityCommonStockSharesOutstanding
      contextRef="PAsOn02_22_2023"
      decimals="INF"
      unitRef="Unit_shares">82046499</dei:EntityCommonStockSharesOutstanding>
    <dei:AuditorFirmId contextRef="P01_01_2022To12_31_2022">42</dei:AuditorFirmId>
    <dei:AuditorName contextRef="P01_01_2022To12_31_2022">Ernst &amp; Young LLP</dei:AuditorName>
    <dei:AuditorLocation contextRef="P01_01_2022To12_31_2022">San Mateo, California</dei:AuditorLocation>
    <dei:DocumentsIncorporatedByReferenceTextBlock contextRef="P01_01_2022To12_31_2022">Portions of the registrant&#x2019;s definitive Proxy Statement for the 2023 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;display:inline;"&gt;10-K&lt;/div&gt; are incorporated by reference in Part III, Items &lt;div style="white-space:nowrap;display:inline;"&gt;10-14&lt;/div&gt; of this Annual Report on Form &lt;div style="white-space:nowrap;display:inline;"&gt;10-K.&lt;/div&gt;</dei:DocumentsIncorporatedByReferenceTextBlock>
    <dei:AmendmentDescription contextRef="P01_01_2022To12_31_2022">NGM Biopharmaceuticals, Inc. (the &#x201c;Company&#x201d;) is filing this Amendment No.&#160;1 (this &#x201c;Amendment&#x201d;) to its Annual Report on Form 10-K for the fiscal year ended December&#160;31, 2022, as filed with the Securities and Exchange Commission (the &#x201c;SEC&#x201d;) on February&#160;28, 2023 (the &#x201c;Original Filing&#x201d;) to correct an inadvertent error that was included in Exhibit 31.2 to the Original Filing. In the version of Exhibit 31.2 filed with the Original Filing, the phrase &#x201c;and internal control over financial reporting (as defined in Exchange Act Rules 13a-15(f) and 15d-15(f))&#x201d; was inadvertently omitted from the introductory language in Section&#160;4 of such exhibit. The Company is filing this Amendment solely for the purpose of correcting the text of the certification contained in Exhibit 31.2 of the Original Filing. No attempt has been made in this Amendment to otherwise modify or update the other disclosures presented in the Original Filing. This Amendment does not reflect events occurring after the Original Filing (i.e., those events occurring after February&#160;28, 2023) 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 Original Filing and the Company&#x2019;s other filings with the SEC. </dei:AmendmentDescription>
</xbrl>
