Master the Formula for Safety Stock and End Stockouts 2026

Stop losing sales to stockouts. Learn the right formula for safety stock to buffer against demand spikes and supplier delays on Shopify, Lazada, and Shopee.

by OneCart Team
Jan 15, 2026 17 min read
thumbnail for this post

A simple way to calculate a basic safety stock buffer is with this formula: (Maximum Daily Sales × Maximum Lead Time) – (Average Daily Sales × Average Lead Time). This gives you a baseline cushion to protect your ecommerce business from sudden sales spikes and supplier delays, helping you avoid painful stockouts.

Why Safety Stock Is Crucial for Ecommerce Success

A worker in a safety vest organizes cardboard boxes on pallets in a clean warehouse.

Think of safety stock as the reserve fuel tank in your car. You don’t plan on using it every day, but it’s an absolute lifesaver when you hit an unexpected traffic jam or find the next petrol station is closed. In ecommerce, this buffer is what protects you from two big uncertainties: sudden surges in customer demand and unpredictable supplier delays.

Getting this number wrong creates expensive problems.

Having too little stock leads to lost sales and can damage your store’s ranking on competitive marketplaces like Shopee, Lazada, and TikTok Shop. But holding too much ties up your cash in warehouse shelves—money that could be spent on marketing or growing your business.

The Real Cost of Guesswork

Without a reliable formula, businesses often fall back on guesswork, and that can be a costly habit. The consequences of getting it wrong ripple through your entire operation, hitting everything from customer happiness to your bottom line.

A well-planned buffer helps you strike a strategic balance.

Holding the right amount of safety stock ensures you can meet customer promises without freezing your working capital in products that just aren’t selling. This balance is fundamental to profitable growth.

This is especially true in today’s market. Post-pandemic supply chains across Southeast Asia are still volatile, making a solid inventory strategy essential for navigating unexpected disruptions.

To get a sense of these ongoing challenges, you can read more in a report by the Asian Development Bank.

The table below breaks down the damage caused by having either too little or too much stock.

The High Cost of Poor Inventory Planning

Impact AreaConsequences of Stockouts (Too Little Stock)Consequences of Overstocking (Too Much Stock)
Sales & RevenueLost sales from unavailable products, especially top-sellers.Cash is tied up in slow-moving inventory, hurting cash flow.
Customer LoyaltyDisappointed customers may buy from competitors instead.Increased holding costs (storage, insurance, obsolescence).
Marketplace RankLower seller scores and visibility due to unfulfilled orders.Risk of products expiring or becoming obsolete.
Operational CostsHigher costs for expedited shipping to restock quickly.Need for markdowns and clearance sales to free up space.
Business GrowthDamaged brand reputation from being unreliable.Capital that could fund marketing or new products is stuck.

As you can see, both extremes are bad for business. Finding that sweet spot is where a good safety stock formula comes in.

The Purpose of a Safety Stock Formula

A clear formula turns inventory management from a guessing game into a science. By using your own historical data, you can build a reliable buffer that’s customised for each product’s unique sales patterns and your supplier’s performance. For a deeper dive into the fundamentals, check out our guide on understanding safety stock and how it prevents stockouts.

This data-driven approach helps you achieve several key goals:

  • Prevent Lost Sales: Keep your most popular products in stock, especially during massive sales events like 11.11.
  • Improve Customer Loyalty: Fulfilling orders consistently and on time builds trust and encourages repeat business.
  • Optimise Cash Flow: Avoid tying up capital in slow-moving items, freeing it up for more profitable ventures.
  • Strengthen Marketplace Performance: High stock availability helps improve your seller score and boosts your visibility.

The Basic Safety Stock Formula for Stable Products

A top-down view of an office desk with a laptop, calculator, smartphone, and tablet showing data.

When you’re dealing with products that have consistent sales and reliable suppliers, you can start with a simple but surprisingly effective formula. It’s the perfect entry point for calculating a buffer without getting tangled up in complex statistics.

This approach is ideal for those bread-and-butter items—the ones that sell steadily but aren’t likely to go viral overnight or see crazy seasonal spikes.

The basic formula for safety stock is:

(Maximum Daily Sales × Maximum Lead Time) – (Average Daily Sales × Average Lead Time)

This calculation creates a buffer by measuring the gap between your absolute worst-case scenario and your typical day-to-day operations. It answers a simple but critical question: “How much extra stock do I need if my biggest sales day ever happens right when my supplier takes the longest they’ve ever taken to deliver?”

Breaking Down the Components

To make this formula work, you need four key pieces of information pulled straight from your sales and purchasing history. Using real numbers from your business, not just guesses, is crucial, or your entire calculation will be off.

  • Maximum Daily Sales: Find the highest number of units you’ve ever sold of a specific product in a single 24-hour period.
  • Maximum Lead Time: Look back at your orders and find the longest time, in days, you’ve ever had to wait for that product to arrive after placing an order.
  • Average Daily Sales: This is the typical number of units you sell per day. Calculate this over a reasonable period, like the last 30 or 90 days.
  • Average Lead Time: The usual time, in days, it takes your supplier to get the stock to your warehouse.

Pulling this info directly from your Shopify analytics or Shopee Seller Centre is the best way to make sure your safety stock is grounded in reality.

A Practical Example for a Shopify Store

Let’s say you run a Shopify store and one of your bestsellers is a particular phone case. You dig into your data from the last three months and find these numbers:

  • Maximum Daily Sales: 25 cases (you had a great flash sale one weekend).
  • Maximum Lead Time: 14 days (your supplier was delayed by a public holiday).
  • Average Daily Sales: 15 cases.
  • Average Lead Time: 10 days.

Now, let’s plug these into the formula.

  1. Calculate your worst-case demand: 25 cases (Max Sales) × 14 days (Max Lead Time) = 350 units.
  2. Calculate your average demand: 15 cases (Avg Sales) × 10 days (Avg Lead Time) = 150 units.
  3. Find the difference: 350150 = 200 units.

The result is your safety stock. You should aim to have 200 extra phone cases on your shelf as a buffer. This stash will see you through unexpected sales surges and supplier hiccups, keeping your customers happy and your sales flowing.

While this basic formula for safety stock is a fantastic starting point, it really shines with predictable products. If you’re selling items with huge swings in demand or have suppliers who are all over the place, you’ll need a more advanced formula to truly protect your business.

How to Calculate Safety stock for Demand Swings

The basic formula is a great starting point for stable, predictable products. But what about that item that suddenly goes viral on TikTok, or sees a massive sales spike during a Lazada flash sale? When customer demand is all over the place, you need a more dynamic formula.

This is where we shift from simple averages to a more statistical approach. We’re essentially going to look at your past sales data, measure how much it typically swings up and down, and build a buffer that can handle those fluctuations.

The formula looks like this:

Safety Stock = Z-score × Standard Deviation of Demand

Let’s break down what these two new parts actually mean for your business.

Understanding Service Level and Z-Score

Think of your service level as an insurance policy against stockouts. It’s a percentage that represents how often you want to have a product in stock when a customer wants to buy it.

A 95% service level, for example, means you’re aiming to meet customer demand 95 out of 100 times. You’re accepting a small, calculated 5% risk of selling out.

The Z-score is simply the statistical number that corresponds to the service level you’ve chosen. A higher service level goal requires a higher Z-score, which naturally leads to holding more safety stock.

Choosing Your Service Level and Z-Score

Here’s a quick reference table to help you match your desired stock availability with the correct Z-score for your calculations.

Desired Service Level (%)Corresponding Z-ScoreWhat This Means for Your Inventory
90%1.28You can meet demand in 9 out of 10 scenarios.
95%1.65You are protected against stockouts 19 out of 20 times.
98%1.96A very high buffer for your most critical, best-selling products.
99%2.33Maximum protection, usually reserved for your absolute A-grade items.

Picking the right service level is a business decision, not just a math problem. For your most profitable, fast-moving products, aiming for a 95-98% service level is a smart move. For slower-moving or less critical items, 90% might be a more cost-effective choice.

Calculating Standard Deviation of Demand

Standard deviation of demand sounds intimidating, but it’s just a way to measure how much your daily sales tend to bounce around the average.

A high standard deviation means your sales are unpredictable and swing wildly—like during a major sales event. A low one means they’re pretty stable and consistent. It gives you a single number to quantify that sales volatility.

This concept isn’t unique to e-commerce. Analysis of Asian equity markets often reveals significant volatility, which mirrors the demand fluctuations online sellers face. Just as investors use strategies to manage market risk, sellers must use statistical tools like standard deviation to manage the financial risks of uncertain demand. You can see more on this in the OECD’s report on Asia’s capital markets.

Practical Example for a Lazada Fashion Item

Let’s put this into practice. Imagine you sell a trending handbag on Lazada. It’s popular, so you want a 95% service level to avoid disappointing customers with an “out of stock” notice. This means you’ll use a Z-score of 1.65.

You pull up your sales data from the past week:

  • Monday: 20 sales
  • Tuesday: 15 sales
  • Wednesday: 45 sales (thanks to a flash sale!)
  • Thursday: 22 sales
  • Friday: 18 sales
  • Saturday: 50 sales
  • Sunday: 25 sales

You can pop these numbers into a simple online calculator or use the STDEV.S function in Google Sheets or Excel. Doing so gives you a standard deviation of approximately 14.2 units. This single number captures the volatility of your handbag sales.

Now, let’s plug it all into the formula:

  1. Safety Stock = Z-score × Standard Deviation of Demand
  2. Safety Stock = 1.65 × 14.2
  3. Safety Stock23.4, which we’ll round up to 24 units.

So, you should aim to hold 24 extra handbags just as a buffer. This statistical method gives you a far more accurate safety net than the basic formula because it’s tailored to the product’s real-world sales patterns. To learn more about how this fits into a bigger strategy, check out our guide on demand planning and forecasting to master your supply chain.

The Advanced Formula for Total Uncertainty

So far, we’ve looked at formulas that handle either surprise sales spikes or frustrating supplier delays—but what happens when you’re hit with both at once? This is the reality for many sellers.

If you’re facing the double-whammy of unpredictable customer demand and inconsistent supplier shipping, you need a formula that accounts for total uncertainty. This is a common headache for businesses in Singapore sourcing products internationally, where lead times can get messy thanks to customs, port congestion, or logistics hiccups.

The advanced formula is the industry standard for managing risk in a volatile supply chain. It might look a bit intimidating, but its goal is simple: create a single, precise buffer that protects you from both types of surprises at the same time.

Safety Stock = Z × √[(Avg Lead Time × SD of Demand²) + (Avg Sales² × SD of Lead Time²)]

This formula gives you a far more accurate safety net than the simpler methods. It does demand more data, but the payoff is a huge reduction in the risk of both stockouts and having your cash tied up in overstocks.

Unpacking the Components

Before we run through an example, let’s quickly break down the moving parts of this formula. You’ll recognise most of them, but seeing how they work together is the key.

  • Z-score: Just like before, this number is tied to your desired service level (e.g., 1.65 for 95%).
  • Average Lead Time: The typical time it takes for your supplier to deliver your order, measured in days.
  • Standard Deviation (SD) of Demand: This measures how much your daily sales tend to swing up or down.
  • Average Sales: Your average daily sales in units.
  • Standard Deviation (SD) of Lead Time: This is the new, crucial piece. It quantifies just how unreliable your supplier’s delivery times are.

This flowchart shows how your service level feeds into your Z-score, which then uses standard deviation to build a reliable buffer against those unexpected demand swings.

Flowchart illustrating safety stock calculation from service level, Z-score, and standard deviation to mitigate demand swings.

The main takeaway here is that aiming for a higher service level means using a larger Z-score, which naturally increases your safety stock to give you a stronger cushion.

A Practical Example for an Internationally Sourced Product

Let’s imagine you sell premium Bluetooth speakers on Shopee, sourced from an overseas supplier. You’re aiming for a 95% service level, which means your Z-score is 1.65. After digging into your sales and supplier data, you come up with these numbers:

  • Average Sales: 30 speakers per day
  • SD of Demand: 8 units
  • Average Lead Time: 25 days
  • SD of Lead Time: 4 days (sometimes delivery is 21 days, other times it stretches to 29)

Now, let’s walk through the calculation step-by-step to keep things simple.

Step 1: Calculate the Demand Variability

First, let’s figure out the part of the formula that covers unpredictable customer demand.

  • (Average Lead Time × SD of Demand²)
  • (25 × 8²) = 25 × 64 = 1,600

Step 2: Calculate the Lead Time Variability

Next, we’ll calculate the part that accounts for your supplier’s inconsistent shipping times.

  • (Average Sales² × SD of Lead Time²)
  • (30² × 4²) = 900 × 16 = 14,400

Step 3: Combine Both and Find the Square Root

Now, we add the two results together and find the square root of the total. This gives you the combined uncertainty you’re facing.

  • √(1,600 + 14,400) = √16,000 ≈ 126.5

Step 4: Multiply by Your Z-Score

Finally, multiply this combined uncertainty figure by your Z-score to get your final safety stock number.

  • 1.65 × 126.5 ≈ 208.7

You should hold a safety stock of 209 speakers. This buffer is precisely tuned to shield your Shopee store from both sudden sales spikes and unexpected shipping delays, ensuring you can keep orders flowing even when things don’t go according to plan.

Putting Your Safety Stock Formula into Practice

Woman in a blue uniform analyzing business data and charts on a laptop in a retail store.

Let’s move from theory to action. This is where these formulas stop being numbers on a page and start protecting your business from stockouts. Knowing how to calculate safety stock is one thing, but efficiently gathering the right data and running the numbers is what turns it into a powerful, day-to-day tool for any ecommerce seller.

The very first step is getting your hands on accurate data. This isn’t about guesswork; it’s about digging into the platforms you already use every day.

Your Data Gathering Checklist

Before you can plug numbers into any formula, you need to know exactly where to find them. Here’s a quick checklist to grab the essential data for each of your products:

  • Sales History: Head over to your Shopee Seller Centre, Lazada Seller Center, or Shopify Analytics and export your daily or weekly sales reports. This is where you’ll find the average and maximum sales figures you need.
  • Lead Time History: This one’s hiding in plain sight in your purchase order records. Note the date you placed an order with a supplier and the date the stock actually arrived. This is critical for calculating your average and maximum lead times.
  • Standard Deviation: You don’t need to be a maths whiz for this. In a spreadsheet like Google Sheets or Excel, just list your daily sales data in a column and use the STDEV.S() function. It will instantly calculate the standard deviation for you.

Actionable Insight: Create a simple spreadsheet for each of your key suppliers. Track every single purchase order’s placed date and received date. After just a few orders, you’ll have a clear, data-backed view of their actual lead time and, more importantly, its variability.

Automating Your Safety Stock Calculations

Manually calculating these formulas for every single SKU is a recipe for headaches and errors, especially as your catalogue grows. This is where automation becomes a total game-changer.

Modern inventory management software is built to do this heavy lifting for you. By connecting directly to your sales channels like Shopee and Shopify, these systems pull all your sales and purchasing data into one central place.

This means the software can automatically:

  1. Track real-time sales velocity for every single SKU.
  2. Analyse historical data to calculate standard deviation.
  3. Monitor supplier lead times straight from your purchase orders.
  4. Continuously run the right formula for safety stock and suggest updated levels.

Implementing these formulas is a crucial part of broader supply chain management that aims to prevent disruptions and keep your logistics smooth. Automation turns what was a static calculation into a dynamic, responsive strategy. This is especially vital when you’re gearing up for huge sales events like 11.11, as the system can recommend increasing your buffer for key products without you needing to manually crunch the numbers.

This approach also aligns with a growing focus on efficiency in modern supply chains. The increasing attention on ESG (Environmental, Social, and Governance) principles in Southeast Asian markets parallels this shift. Accurate, automated safety stock calculations help minimise waste from overstocking and reduce the carbon footprint from last-minute expedited shipping, fitting perfectly with these sustainable business goals.

The goal is to move beyond static spreadsheets and towards a system that adjusts your safety stock as the market changes. If you’re looking for a tool to help with this, you can experiment with our free safety stock calculator to see how different variables impact your buffer needs.

Common Questions About Safety Stock Formulas

Even with the right formulas, you’ll run into practical questions the moment you start applying them to your business. Let’s tackle some of the most common ones we hear from sellers.

Getting these details right is what separates a theoretical calculation from a real-world, profit-protecting system.

How Often Should I Recalculate My Safety Stock?

You should aim to recalculate your safety stock at least quarterly. For your fast-moving or seasonal products, though, monthly recalculations are much better.

If you launch a big marketing campaign or see a new trend taking off, it’s smart to review your numbers immediately. Using inventory management software automates this by constantly analysing real-time sales data, which allows for far more dynamic and accurate adjustments.

What Service Level Should I Aim For?

The right service level depends entirely on the product. Use a tiered approach rather than one number for everything.

  • A-Grade Items: For your bestsellers, aim high—think 95% to 98%. A stockout here is incredibly expensive in lost sales and customer trust.
  • C-Grade Items: For your slower-moving items, a lower service level of 85% to 90% is often more cost-effective. The cost of holding that extra inventory might outweigh the risk of an occasional stockout.

Analyse your product margins and sales velocity to make an informed decision for each SKU. This tiered approach ensures you invest your capital where it delivers the biggest returns.

The goal is strategic protection. You want maximum coverage for the products that actually drive your business, and you’re willing to accept a slightly higher, calculated risk on the items that contribute less to your bottom line.

What If My Supplier Lead Times Are Very Inconsistent?

Inconsistent lead times are exactly why the advanced safety stock formula is so valuable—it’s designed to factor in that very problem. If your supplier’s delivery schedule is all over the place, that formula is your best tool.

Start by meticulously tracking the placement and arrival dates for every single order to get accurate data. If one supplier is consistently unreliable, use a higher safety stock for their products while you start looking for alternatives.

Sometimes, just talking to them helps. Ask your supplier for delivery forecasts and shipping updates. This simple step can give you the visibility needed to tighten your lead time estimates and reduce how much buffer stock you need to carry.


Ready to stop guessing and start calculating? OneCart brings your sales and purchasing data from Shopee, Lazada, and Shopify into one place, making it easy to gather the numbers you need for accurate safety stock calculations. Stop overselling and optimise your capital by automating your inventory management. Learn more and get started at https://www.getonecart.com.

Want More Sales With E-Commerce?

Automate & Scale Your Online Business with OneCart

Start a Free Trial

Used by hundreds of merchants in Singapore & Southeast Asia