Increasing urban density promotes a greater social role for cities. The current low-carbon city development goals put forward higher requirements for carbon performance. Based on the viewpoint of minimizing natural resource input and maximizing value acquisition in ecological benefits, the influence of urban density on spatial carbon performance is analyzed by polynomial function relationship, and Beijing and Shanghai with different urban function positioning are taken as examples for comparative analysis. Combined with Point-of-Interest (POI), the classification benchmark of industrial activities was established, and the spatial kernel density of ArcGIS software was used to analyze the industrial agglomeration characteristics of the two cities. The results show that: 1) The “increase-decrease-increase-decrease” trend of urban spatial carbon performance over time fluctuates around the unary linear trend of urban density.2) Population and building density are too low or too high, which is not conducive to emission reduction. The change of economic density is influenced by the industrial structure. The change of urban density is negatively correlated with the growth rate of spatial carbon performance. In a certain development stage, the increase of urban density will inhibit the growth of spatial carbon performance to some extent. 3) Maintaining the original economic and industrial structure, the increase in economic density brought by the simple expansion of scale is not conducive to emission reduction. The increase of economic density brought by the transformation of economic or industrial structure and the reduction of the proportion of secondary industry is conducive to urban emission reduction.