<?xml version="1.0" encoding="utf-8"?>
<xbrl
  xmlns="http://www.xbrl.org/2003/instance"
  xmlns:dei="http://xbrl.sec.gov/dei/2022"
  xmlns:link="http://www.xbrl.org/2003/linkbase"
  xmlns:xlink="http://www.w3.org/1999/xlink">
    <link:schemaRef xlink:href="ngm-20230809.xsd" xlink:type="simple"/>
    <context id="duration_2023-08-09_to_2023-08-09">
        <entity>
            <identifier scheme="http://www.sec.gov/CIK">0001426332</identifier>
        </entity>
        <period>
            <startDate>2023-08-09</startDate>
            <endDate>2023-08-09</endDate>
        </period>
    </context>
    <dei:EntityRegistrantName
      contextRef="duration_2023-08-09_to_2023-08-09"
      id="Hidden_dei_EntityRegistrantName">NGM BIOPHARMACEUTICALS INC</dei:EntityRegistrantName>
    <dei:AmendmentFlag contextRef="duration_2023-08-09_to_2023-08-09">true</dei:AmendmentFlag>
    <dei:EntityCentralIndexKey
      contextRef="duration_2023-08-09_to_2023-08-09"
      id="Hidden_dei_EntityCentralIndexKey">0001426332</dei:EntityCentralIndexKey>
    <dei:DocumentType contextRef="duration_2023-08-09_to_2023-08-09">8-K/A</dei:DocumentType>
    <dei:DocumentPeriodEndDate contextRef="duration_2023-08-09_to_2023-08-09">2023-08-09</dei:DocumentPeriodEndDate>
    <dei:EntityIncorporationStateCountryCode contextRef="duration_2023-08-09_to_2023-08-09">DE</dei:EntityIncorporationStateCountryCode>
    <dei:EntityFileNumber contextRef="duration_2023-08-09_to_2023-08-09">001-38853</dei:EntityFileNumber>
    <dei:EntityTaxIdentificationNumber contextRef="duration_2023-08-09_to_2023-08-09">26-1679911</dei:EntityTaxIdentificationNumber>
    <dei:EntityAddressAddressLine1 contextRef="duration_2023-08-09_to_2023-08-09">333 Oyster Point Boulevard</dei:EntityAddressAddressLine1>
    <dei:EntityAddressCityOrTown contextRef="duration_2023-08-09_to_2023-08-09">South San Francisco</dei:EntityAddressCityOrTown>
    <dei:EntityAddressStateOrProvince contextRef="duration_2023-08-09_to_2023-08-09">CA</dei:EntityAddressStateOrProvince>
    <dei:EntityAddressPostalZipCode contextRef="duration_2023-08-09_to_2023-08-09">94080</dei:EntityAddressPostalZipCode>
    <dei:CityAreaCode contextRef="duration_2023-08-09_to_2023-08-09">(650)</dei:CityAreaCode>
    <dei:LocalPhoneNumber contextRef="duration_2023-08-09_to_2023-08-09">243-5555</dei:LocalPhoneNumber>
    <dei:WrittenCommunications contextRef="duration_2023-08-09_to_2023-08-09">false</dei:WrittenCommunications>
    <dei:SolicitingMaterial contextRef="duration_2023-08-09_to_2023-08-09">false</dei:SolicitingMaterial>
    <dei:PreCommencementTenderOffer contextRef="duration_2023-08-09_to_2023-08-09">false</dei:PreCommencementTenderOffer>
    <dei:PreCommencementIssuerTenderOffer contextRef="duration_2023-08-09_to_2023-08-09">false</dei:PreCommencementIssuerTenderOffer>
    <dei:Security12bTitle contextRef="duration_2023-08-09_to_2023-08-09">Common Stock, par value $0.001 per share</dei:Security12bTitle>
    <dei:TradingSymbol contextRef="duration_2023-08-09_to_2023-08-09">NGM</dei:TradingSymbol>
    <dei:SecurityExchangeName contextRef="duration_2023-08-09_to_2023-08-09">NASDAQ</dei:SecurityExchangeName>
    <dei:EntityEmergingGrowthCompany contextRef="duration_2023-08-09_to_2023-08-09">false</dei:EntityEmergingGrowthCompany>
    <dei:AmendmentDescription contextRef="duration_2023-08-09_to_2023-08-09">NGM Biopharmaceuticals, Inc. (the &#x201c;Company&#x201d;) is filing this amendment to its Current Report on Form 8-K filed with the SEC on August&#160;11, 2023 (the &#x201c;Original Filing&#x201d;) solely for the purpose of reporting, in accordance with Instruction 2 to Item 5.02 of Form 8-K, the compensation determinations made in connection with Irene Perlich&#x2019;s appointment as the Company&#x2019;s principal accounting officer. At the time the Original Filing was made, the terms of such compensation had not yet been determined. This amendment does not otherwise revise the Original Filing in any way.</dei:AmendmentDescription>
</xbrl>
