Maths

GDP Calculator

Add up GDP from consumption, investment, government and net exports, or turn nominal GDP into real GDP.

By Nitin Raturi · Last reviewed

Your figures

How to use the GDP Calculator

Add up GDP from its spending components, or adjust nominal GDP for prices.

  1. Choose GDP from spending or real GDP.
  2. Enter the figures, all in the same currency and unit.
  3. Read GDP with each component’s share, or real GDP in base-year prices.

Good to know

  • Imports are subtracted because their value is already counted in C, I and G.
  • A deflator above 100 means prices are higher than in the base year.
Calculate

Calculate

Add up GDP from spending, or turn nominal GDP into real GDP.

How to fill it in

  • GDP from spending: enter C, I, G, X and M.
  • Real GDP: enter nominal GDP and the deflator.

Consumption (C)

Household spending on goods and services.

How to fill it in

  • Use the same currency and unit for every figure, such as ₹ crore or $ trillion.
  • Enter 0 or more.

Example

OpenStax’s US table: 14.0 + 3.6 + 3.9 + 2.1 − 2.7 = 20.9 trillion dollars.

Investment (I)

Business spending on equipment and buildings, new housing, and the change in inventories.

How to fill it in

  • Use the same currency and unit for every figure, such as ₹ crore or $ trillion.
  • It can be negative if inventories fell a lot.

Government spending (G)

Government purchases of goods and services. Transfers such as pensions are not included.

How to fill it in

  • Use the same currency and unit for every figure, such as ₹ crore or $ trillion.
  • Enter 0 or more.

Exports (X)

Goods and services sold to other countries.

How to fill it in

  • Use the same currency and unit for every figure, such as ₹ crore or $ trillion.
  • Enter 0 or more.

Imports (M)

Goods and services bought from other countries. They are subtracted.

How to fill it in

  • Use the same currency and unit for every figure, such as ₹ crore or $ trillion.
  • Enter a positive number; the calculator subtracts it.

Example

In the US example net exports are -0.6 trillion: imports exceed exports.

GDP (expenditure approach)

20.90

GDP = 14 + 3.6 + 3.9 + (2.1 − 2.7) = 20.90. Consumption is 67.0% of it.

Consumption (C)
67.0% of GDP
Investment (I)
17.2% of GDP
Government spending (G)
18.7% of GDP
Exports (X)
10.0% of GDP
Imports (M)
-12.9% of GDP
Net exports (X − M)
-0.60

GDP = C + I + G + (X − M), in the same units as your figures. Imports are subtracted because they are already counted inside C, I and G.

How this calculator works

  1. Step 1Add spendingC + I + G + (X − M)Who bought the economy’s output.
  2. Step 2Remove pricesnominal ÷ (deflator ÷ 100)GDP at base-year prices.
  3. Step 3Compareshares and real valuesAcross components or years.

GDP measures what an economy produces. On the demand side, every rupee of output is bought by households, businesses, government or foreigners, so GDP is the sum of their spending.

Imports are subtracted because they are already inside consumption, investment and government spending. Net exports can be negative.

Worked example: OpenStax’s US table

GDP from spending, $ trillion
GDP
C + I + G + (X − M)
  1. Consumption14.0
  2. Investment3.6
  3. Government3.9
  4. Net exports2.1 − 2.7-0.6
  5. GDP20.9

This is Table 6.1 in OpenStax Principles of Macroeconomics, which also gives $20.9 trillion.

Read the result

  • Consumption67.0%
  • Investment17.2%
  • Government18.7%
  • Exports10.0%
  • Imports (subtracted)-12.9%
Each component as a share of GDP

Consumption is usually the largest part of GDP. Shares here come from the rounded table, so they differ slightly from OpenStax’s published percentages.

Real GDP

  • 1960$3,267.5 billionNominal $542.4 billion at a deflator of 16.6.
  • 2015$17,388.7 billionNominal $18,206 billion at a deflator of 104.7.

Dividing by the deflator removes price changes, so years can be compared by quantity produced. A deflator below 100 means prices were lower than in the base year, so real GDP is higher than nominal.

Assumptions and limits

  • Same unitsAll figures in one currency and scale.
  • Same yearUse the deflator for the nominal figure’s year.
  • Base 100Enter the deflator as published, e.g. 104.7.
  • No statisticsDiscrepancies in official accounts are not modelled.

Real GDP removes price changes. The same idea turns any future sum into today's money.

To adjust a rupee amount for price rises, use the inflation calculator. For a growth rate between two values, the CAGR calculator gives the yearly rate, and the percentage calculator the total change.

Common mistakes

  • Mistake: Adding imports to GDP.

    Instead: Subtract them; they were produced abroad.

  • Mistake: Counting pensions and subsidies in G.

    Instead: Only government purchases count.

  • Mistake: Entering the deflator as 1.047.

    Instead: Use the published index, 104.7.

Checking the method

A separate script re-works every golden value in exact fractions and reproduces OpenStax’s Table 6.1 and both real GDP examples.

Read how we test our calculators, or browse more maths calculators.

Frequently asked questions

How do you calculate GDP by the expenditure method?

Add consumption, investment, government purchases and net exports: GDP = C + I + G + (X − M). OpenStax’s US table gives 20.9 trillion dollars.

Why are imports subtracted?

Imported goods are already counted in C, I and G but were produced abroad. In the US example net exports are -0.6 trillion.

How do you turn nominal GDP into real GDP?

Divide by the deflator over 100. $542.4 billion at 16.6 is $3,267.5 billion in 2012 prices.

What does a deflator above 100 mean?

Prices are above the base year, so real GDP is below nominal: $18,206 billion at 104.7 is $17,388.7 billion.

Can I use rupees?

Yes. Any currency and unit works, such as ₹ crore, as long as every figure uses the same one.

Sources and methodology

The formulas are standard time-value-of-money results. We check every figure against golden values worked out independently, by closed form and by month-by-month simulation; see the methodology.

Written and maintained by Nitin Raturi, a software engineer (about the author). Last reviewed 4 Nov 2026; next review due by . Found an error? Tell us.

Changelog

  • : Initial release.