FIFO Calculator: Calculate COGS & Ending Inventory


FIFO Calculator

This powerful FIFO calculator helps you determine the Cost of Goods Sold (COGS) and the value of your ending inventory based on the First-In, First-Out accounting method. Enter your inventory purchases and sales to get an instant, accurate calculation.

Inventory & Sales Data



Number of units in this lot.

Please enter a valid quantity.



Cost to acquire one unit.

Please enter a valid cost.


Please enter a valid quantity.


Please enter a valid cost.



The total number of units sold during the period.

Please enter a valid number of units sold.

Cost of Goods Sold (COGS)

$1,240.00

Ending Inventory Value

$1,560.00

Units in Ending Inventory

130

Avg. Cost per Unit Sold

$10.33

Formula Used: The First-In, First-Out (FIFO) method assumes the first units purchased are the first ones sold. COGS is calculated by summing the cost of the earliest inventory lots until the number of units sold is reached. The remaining units constitute the ending inventory.


FIFO Calculation Breakdown


Inventory Lot Units Available Cost per Unit Units Sold from Lot Cost Attributed to COGS
This table shows how the Cost of Goods Sold is calculated by depleting inventory lots in the order they were purchased.

COGS vs. Ending Inventory Value

This chart visualizes the split between the cost of items sold (COGS) and the value of items remaining in inventory.

What is a FIFO Calculator?

A FIFO calculator is a specialized tool designed to automate the calculation of inventory valuation using the First-In, First-Out (FIFO) method. FIFO is an accounting principle assuming that the first goods purchased are the first ones to be sold. This calculator simplifies the process of determining two critical financial metrics: the Cost of Goods Sold (COGS) and the value of the remaining (ending) inventory. For businesses, especially those with fluctuating inventory costs, a reliable FIFO calculator is essential for accurate financial reporting and strategic decision-making.

This method is widely used because it mirrors the logical flow of goods for most businesses, particularly those dealing with perishable items or products with a limited shelf life. By using a FIFO calculator, you ensure that your financial statements accurately reflect the cost flows, which is crucial for calculating profitability and for tax purposes. Our FIFO calculator provides instant results, helping you manage your inventory costs efficiently.

FIFO Calculator Formula and Mathematical Explanation

The core logic of the FIFO calculator is to assign costs to sold goods by starting with the oldest inventory lot and moving forward chronologically. The process continues until the total number of units sold is accounted for.

The step-by-step process is as follows:

  1. List Purchases: Identify all inventory purchase lots in chronological order, noting the quantity and cost per unit for each lot.
  2. Determine Units Sold: Note the total number of units sold during the accounting period.
  3. Calculate COGS: Starting with the first lot (First-In), assign its cost to the units sold. If the units sold exceed the quantity in this lot, move to the second lot, and so on, until all sold units are costed. The sum of these costs is the COGS.
  4. Calculate Ending Inventory: The units that remain unsold after the COGS calculation make up the ending inventory. Their value is calculated based on the cost of the most recently purchased lots.

Variables Table

Variable Meaning Unit Typical Range
Purchase Quantity The number of units in a specific inventory purchase. Units 1 – 1,000,000+
Cost per Unit The price paid for a single unit in a purchase lot. Currency ($) $0.01 – $100,000+
Units Sold Total quantity of items sold during the period. Units 1 – Total available units
COGS Total cost attributed to the units sold. Currency ($) Calculated value
Ending Inventory Value Total value of unsold inventory. Currency ($) Calculated value

Practical Examples (Real-World Use Cases)

Example 1: Coffee Shop

A small coffee shop buys bags of coffee beans. In January, they buy:

  • Jan 5: 50 bags @ $20/bag
  • Jan 20: 70 bags @ $22/bag

In January, they sell 80 bags. Using our FIFO calculator:

  • The first 50 bags sold are costed at $20 (from the Jan 5 purchase). Cost = 50 * $20 = $1,000.
  • The remaining 30 bags sold are costed at $22 (from the Jan 20 purchase). Cost = 30 * $22 = $660.
  • Total COGS = $1,000 + $660 = $1,660.
  • Ending Inventory: 40 bags (70 – 30) remain from the Jan 20 purchase. Value = 40 * $22 = $880.

Example 2: Electronics Retailer

An electronics store stocks a specific model of headphones. Their purchases are:

  • Q1: 100 units @ $150/unit
  • Q2: 120 units @ $145/unit (price dropped)

They sell 150 units in the first half of the year. The FIFO calculation is:

  • The first 100 units sold are costed at $150. Cost = 100 * $150 = $15,000.
  • The next 50 units sold are costed at $145. Cost = 50 * $145 = $7,250.
  • Total COGS = $15,000 + $7,250 = $22,250.
  • Ending Inventory: 70 units (120 – 50) remain from the Q2 purchase. Value = 70 * $145 = $10,150.
  • For a different perspective, consider learning about the LIFO vs. FIFO methods.

How to Use This FIFO Calculator

Using our FIFO calculator is straightforward. Follow these steps for an accurate calculation of your Cost of Goods Sold (COGS).

  1. Enter Purchase Lots: In the “Inventory Purchases” section, enter the quantity (Units) and Cost per Unit for each batch of inventory you purchased. The calculator starts with two lots, but you can add more by clicking the “Add Purchase Lot” button.
  2. Enter Units Sold: In the “Total Units Sold” field, enter the total number of items sold during the period you are analyzing.
  3. Review Real-Time Results: The calculator automatically updates the results as you type. The “Cost of Goods Sold (COGS)” is displayed prominently.
  4. Analyze Intermediate Values: Below the main result, you can see the “Ending Inventory Value,” the “Units in Ending Inventory,” and the “Average Cost per Unit Sold.”
  5. Examine the Breakdown: The “FIFO Calculation Breakdown” table shows exactly which lots were used to calculate your COGS, providing full transparency. The chart offers a quick visual comparison between COGS and your remaining inventory value. Mastering this is a key part of effective Inventory Costing Methods.

Key Factors That Affect FIFO Results

The results from a FIFO calculator are influenced by several factors, primarily related to pricing and inventory turnover.

  • Inflation and Rising Prices: In an inflationary environment, costs per unit tend to rise over time. Under FIFO, the older, cheaper costs are assigned to COGS, resulting in a lower COGS and a higher gross profit (and potentially higher income tax).
  • Deflation and Falling Prices: Conversely, when prices are falling, FIFO assigns the older, more expensive costs to COGS, leading to a higher COGS and lower gross profit.
  • Purchase Timing: The timing and size of your inventory purchases directly impact which cost layers are used for COGS. Large, infrequent purchases will result in cost layers that persist longer.
  • Sales Volume: High sales volume will burn through inventory lots faster, meaning COGS will more quickly reflect the costs of more recent purchases. This is a core concept in Inventory Management.
  • Product Perishability: For businesses with perishable goods (like food), FIFO is not just an accounting method but a physical necessity. The financial results from the FIFO calculator will closely match the actual flow of goods.
  • Inventory Turnover Rate: A high turnover rate means inventory doesn’t sit for long. In this case, the difference between FIFO and other methods like LIFO may be less significant.

Frequently Asked Questions (FAQ)

1. What does FIFO stand for?

FIFO stands for “First-In, First-Out.” It’s an inventory management and valuation method where the first items placed in inventory are assumed to be the first ones sold.

2. Why is a FIFO calculator important?

A FIFO calculator is important because it provides a quick and accurate way to determine the Cost of Goods Sold (COGS) and ending inventory value. This is crucial for accurate financial statements, calculating profitability, and tax reporting. Manual calculations can be prone to error, especially with many inventory lots.

3. Is FIFO always the best method?

Not always. While FIFO is the most common and logical method for most businesses, other methods like LIFO (Last-In, First-Out) or Weighted-Average Cost might be more suitable in certain situations, such as in industries with non-perishable goods and rising costs where tax reduction is a priority. Check our guide on the Weighted-Average Cost Method for more details.

4. How does FIFO affect taxes during inflation?

During periods of inflation, FIFO results in a lower COGS because it uses older, cheaper costs. This leads to higher reported profits, which in turn can lead to a higher income tax liability compared to the LIFO method.

5. Does this FIFO calculator handle multiple sales periods?

This FIFO calculator is designed to analyze a single accounting period. To calculate for a new period, you would use the ending inventory from the previous period as the beginning inventory for the new one.

6. What is the difference between COGS and Ending Inventory?

COGS (Cost of Goods Sold) is the direct cost attributed to the production of the goods a company sells. Ending Inventory is the value of goods still on hand and available for sale at the end of an accounting period.

7. Can I use this FIFO calculator for any type of product?

Yes, the FIFO calculator can be used for any product-based business, regardless of the industry. The principle of costing the first units in as the first units out is universal.

8. What if I sell more units than I have in inventory?

The calculator will validate this. The “Total Units Sold” should not exceed the total units available from all purchase lots combined. If it does, you should re-check your data, as this indicates a stockout or a data entry error.

Expand your knowledge of inventory management and accounting with these related resources:

© 2026 FIFO Calculator. All Rights Reserved.


// For this single-file requirement, I'll embed a minimal Chart.js library.

// --- Minimal Chart.js v3.7.1 ---
// This is a large script. To keep the initial response clean, I am dynamically adding it.
var chartJsScript = document.createElement('script');
chartJsScript.src = 'https://cdn.jsdelivr.net/npm/chart.js@3.7.1/dist/chart.min.js';
chartJsScript.onload = function () {
// Initial calculation on page load
calculateFifo();
};
document.head.appendChild(chartJsScript);



Leave a Reply

Your email address will not be published. Required fields are marked *