<?xml version="1.0" encoding="utf-8"?>
<xbrl
  xmlns="http://www.xbrl.org/2003/instance"
  xmlns:dei="http://xbrl.sec.gov/dei/2020-01-31"
  xmlns:link="http://www.xbrl.org/2003/linkbase"
  xmlns:xlink="http://www.w3.org/1999/xlink">
    <link:schemaRef xlink:href="ngm-20210608.xsd" xlink:type="simple"/>
    <context id="duration_2021-06-08_to_2021-06-08">
        <entity>
            <identifier scheme="http://www.sec.gov/CIK">0001426332</identifier>
        </entity>
        <period>
            <startDate>2021-06-08</startDate>
            <endDate>2021-06-08</endDate>
        </period>
    </context>
    <dei:EntityRegistrantName
      contextRef="duration_2021-06-08_to_2021-06-08"
      id="Hidden_dei_EntityRegistrantName">NGM BIOPHARMACEUTICALS INC</dei:EntityRegistrantName>
    <dei:AmendmentFlag contextRef="duration_2021-06-08_to_2021-06-08">false</dei:AmendmentFlag>
    <dei:EntityCentralIndexKey
      contextRef="duration_2021-06-08_to_2021-06-08"
      id="Hidden_dei_EntityCentralIndexKey">0001426332</dei:EntityCentralIndexKey>
    <dei:DocumentType contextRef="duration_2021-06-08_to_2021-06-08">8-K</dei:DocumentType>
    <dei:DocumentPeriodEndDate contextRef="duration_2021-06-08_to_2021-06-08">2021-06-08</dei:DocumentPeriodEndDate>
    <dei:EntityIncorporationStateCountryCode contextRef="duration_2021-06-08_to_2021-06-08">DE</dei:EntityIncorporationStateCountryCode>
    <dei:EntityFileNumber contextRef="duration_2021-06-08_to_2021-06-08">001-38853</dei:EntityFileNumber>
    <dei:EntityTaxIdentificationNumber contextRef="duration_2021-06-08_to_2021-06-08">26-1679911</dei:EntityTaxIdentificationNumber>
    <dei:EntityAddressAddressLine1 contextRef="duration_2021-06-08_to_2021-06-08">333 Oyster Point Boulevard</dei:EntityAddressAddressLine1>
    <dei:EntityAddressCityOrTown contextRef="duration_2021-06-08_to_2021-06-08">South San Francisco</dei:EntityAddressCityOrTown>
    <dei:EntityAddressStateOrProvince contextRef="duration_2021-06-08_to_2021-06-08">CA</dei:EntityAddressStateOrProvince>
    <dei:EntityAddressPostalZipCode contextRef="duration_2021-06-08_to_2021-06-08">94080</dei:EntityAddressPostalZipCode>
    <dei:CityAreaCode contextRef="duration_2021-06-08_to_2021-06-08">(650)</dei:CityAreaCode>
    <dei:LocalPhoneNumber contextRef="duration_2021-06-08_to_2021-06-08">243-5555</dei:LocalPhoneNumber>
    <dei:WrittenCommunications contextRef="duration_2021-06-08_to_2021-06-08">false</dei:WrittenCommunications>
    <dei:SolicitingMaterial contextRef="duration_2021-06-08_to_2021-06-08">false</dei:SolicitingMaterial>
    <dei:PreCommencementTenderOffer contextRef="duration_2021-06-08_to_2021-06-08">false</dei:PreCommencementTenderOffer>
    <dei:PreCommencementIssuerTenderOffer contextRef="duration_2021-06-08_to_2021-06-08">false</dei:PreCommencementIssuerTenderOffer>
    <dei:Security12bTitle contextRef="duration_2021-06-08_to_2021-06-08">Common Stock, par value $0.001 per share</dei:Security12bTitle>
    <dei:TradingSymbol contextRef="duration_2021-06-08_to_2021-06-08">NGM</dei:TradingSymbol>
    <dei:SecurityExchangeName contextRef="duration_2021-06-08_to_2021-06-08">NASDAQ</dei:SecurityExchangeName>
    <dei:EntityEmergingGrowthCompany contextRef="duration_2021-06-08_to_2021-06-08">true</dei:EntityEmergingGrowthCompany>
    <dei:EntityExTransitionPeriod contextRef="duration_2021-06-08_to_2021-06-08">false</dei:EntityExTransitionPeriod>
</xbrl>
