<?xml version="1.0" encoding="utf-8"?>
<xbrl
  xmlns="http://www.xbrl.org/2003/instance"
  xmlns:dei="http://xbrl.sec.gov/dei/2021q4"
  xmlns:link="http://www.xbrl.org/2003/linkbase"
  xmlns:xlink="http://www.w3.org/1999/xlink">
    <link:schemaRef xlink:href="ngm-20220426.xsd" xlink:type="simple"/>
    <context id="duration_2022-04-26_to_2022-04-26">
        <entity>
            <identifier scheme="http://www.sec.gov/CIK">0001426332</identifier>
        </entity>
        <period>
            <startDate>2022-04-26</startDate>
            <endDate>2022-04-26</endDate>
        </period>
    </context>
    <dei:EntityCentralIndexKey
      contextRef="duration_2022-04-26_to_2022-04-26"
      id="Hidden_dei_EntityCentralIndexKey_duration_2022-04-26_to_2022-04-26">0001426332</dei:EntityCentralIndexKey>
    <dei:DocumentType contextRef="duration_2022-04-26_to_2022-04-26">8-K/A</dei:DocumentType>
    <dei:AmendmentFlag contextRef="duration_2022-04-26_to_2022-04-26">true</dei:AmendmentFlag>
    <dei:DocumentPeriodEndDate contextRef="duration_2022-04-26_to_2022-04-26">2022-04-26</dei:DocumentPeriodEndDate>
    <dei:EntityRegistrantName contextRef="duration_2022-04-26_to_2022-04-26">NGM Biopharmaceuticals, Inc.</dei:EntityRegistrantName>
    <dei:EntityIncorporationStateCountryCode contextRef="duration_2022-04-26_to_2022-04-26">DE</dei:EntityIncorporationStateCountryCode>
    <dei:EntityFileNumber contextRef="duration_2022-04-26_to_2022-04-26">001-38853</dei:EntityFileNumber>
    <dei:EntityTaxIdentificationNumber contextRef="duration_2022-04-26_to_2022-04-26">26-1679911</dei:EntityTaxIdentificationNumber>
    <dei:EntityAddressAddressLine1 contextRef="duration_2022-04-26_to_2022-04-26">333 Oyster Point Boulevard</dei:EntityAddressAddressLine1>
    <dei:EntityAddressCityOrTown contextRef="duration_2022-04-26_to_2022-04-26">South San Francisco</dei:EntityAddressCityOrTown>
    <dei:EntityAddressStateOrProvince contextRef="duration_2022-04-26_to_2022-04-26">CA</dei:EntityAddressStateOrProvince>
    <dei:EntityAddressPostalZipCode contextRef="duration_2022-04-26_to_2022-04-26">94080</dei:EntityAddressPostalZipCode>
    <dei:CityAreaCode contextRef="duration_2022-04-26_to_2022-04-26">650</dei:CityAreaCode>
    <dei:LocalPhoneNumber contextRef="duration_2022-04-26_to_2022-04-26">243-5555</dei:LocalPhoneNumber>
    <dei:WrittenCommunications contextRef="duration_2022-04-26_to_2022-04-26">false</dei:WrittenCommunications>
    <dei:SolicitingMaterial contextRef="duration_2022-04-26_to_2022-04-26">false</dei:SolicitingMaterial>
    <dei:PreCommencementTenderOffer contextRef="duration_2022-04-26_to_2022-04-26">false</dei:PreCommencementTenderOffer>
    <dei:PreCommencementIssuerTenderOffer contextRef="duration_2022-04-26_to_2022-04-26">false</dei:PreCommencementIssuerTenderOffer>
    <dei:Security12bTitle contextRef="duration_2022-04-26_to_2022-04-26">Common Stock, par value $0.001 per share</dei:Security12bTitle>
    <dei:TradingSymbol contextRef="duration_2022-04-26_to_2022-04-26">NGM</dei:TradingSymbol>
    <dei:SecurityExchangeName contextRef="duration_2022-04-26_to_2022-04-26">NASDAQ</dei:SecurityExchangeName>
    <dei:EntityEmergingGrowthCompany contextRef="duration_2022-04-26_to_2022-04-26">false</dei:EntityEmergingGrowthCompany>
    <dei:AmendmentDescription contextRef="duration_2022-04-26_to_2022-04-26"> On March 10, 2022, NGM Biopharmaceuticals, Inc. (the &#x201c;Company&#x201d;) filed a Current Report on Form 8-K (the &#x201c;Original Form 8-K&#x201d;) disclosing that, on March&#160;10, 2022, the Company received notice from Fidelity Investments Institutional Services Company (&#x201c;Fidelity&#x201d;) advising of an upcoming blackout period (the &#x201c;Blackout Period&#x201d;) with respect to the NGM Biopharmaceuticals Matching Plan and the NGM Biopharmaceuticals 401(k) Plan (respectively, the &#x201c;Matching Plan&#x201d; and the &#x201c;401(k) Plan&#x201d;), each of which include funds that are invested in the Company&#x2019;s common stock, due to the merger of the Matching Plan into the 401(k) Plan. The Company also disclosed in the Original Form 8-K that the Blackout Period was expected to end on May&#160;13, 2022.This Amendment No.&#160;1 to the Original Form 8-K (&#x201c;Amendment&#x201d;) is being filed solely to disclose that, on April&#160;26, 2022, the Company received notice from Fidelity that the Blackout Period ended earlier than expected.Other than providing the update in Item 5.04 below, no updates have been made to the Original Form 8-K. Accordingly, this Amendment should be read in conjunction with the Original Form 8-K.</dei:AmendmentDescription>
</xbrl>
