Dashboard

Build a Recipe Cost Calculator With AI

A step-by-step plan for building a recipe cost calculator with an AI app builder, with the data model, the formulas, a worked pizza example and test cases to catch errors.

Manuele Estivo
Manuele Estivo
Growth & SEO Lead
17 October 20261 min read

To build a recipe cost calculator with AI, you need three tables (ingredients, recipes, and recipe lines), one conversion rule (everything stored in grams or millilitres), and one formula that divides by usable yield. An AI app builder can generate the screens and the database from a clear description. The part it will not get right unless you tell it is the arithmetic, so this guide does the arithmetic first and then gives you the numbers to test against.

The goal is simple: enter what you paid for ingredients, and see what each portion costs and what to charge. It suits cafes, bakeries, caterers and home food businesses that currently do this in a notebook.

The data model

Keep it small. Three tables are enough:

  • Ingredients: name, purchase price, pack size in grams or millilitres, and usable yield as a percentage.

  • Recipes: name, number of portions the recipe makes, and target food cost percentage.

  • Recipe lines: which ingredient, and how many grams or millilitres the recipe uses.

Store every quantity in grams or millilitres. A cup of flour and a cup of sugar do not weigh the same, so any cup, tablespoon or "bunch" entry should be converted once, at entry time, using a weight you measured. Letting the app store loose units is how costs drift without anyone noticing.

The formulas

For each ingredient line:

  1. Price per gram = purchase price divided by pack size in grams.

  2. Usable yield matters when you pay for the whole item but use part of it. Cost of the amount used = grams used divided by yield, times price per gram.

  3. Recipe cost = the sum of all line costs.

  4. Cost per portion = recipe cost divided by portions.

  5. Suggested price = cost per portion divided by your target food cost percentage.

Yield is the step people skip. Herbs, fruit and vegetables lose weight to stems, cores and peel. The USDA publishes yield tables in its Food Buying Guide, where, for example, 1 lb of apples as purchased gives 0.93 lb once cored and unpeeled. Use a table like that, or your own weigh-in, to set each ingredient's yield.

A worked example

One margherita pizza. The prices below are invented for the arithmetic, so replace them with your own invoices.

Ingredient

Price and pack

Price per gram or ml

Used

Yield

Cost

Flour

£18.00 for 25,000 g

£0.00072

250 g

100%

£0.18

Mozzarella

£13.00 for 2,000 g

£0.00650

120 g

100%

£0.78

Passata

£4.50 for 3,000 g

£0.00150

80 g

100%

£0.12

Fresh basil

£1.20 for 30 g

£0.04000

5 g

50%

£0.40

Olive oil

£30.00 for 5,000 ml

£0.00600

10 ml

100%

£0.06

The basil line is the one to study. You use 5 g, but only half of what you buy is usable leaf, so you pay for 10 g: 10 times £0.04 is £0.40. Without the yield step that line would show £0.20 and the pizza would look cheaper than it is.

Recipe cost is £0.18 + £0.78 + £0.12 + £0.40 + £0.06 = £1.54 for one pizza. Say your target food cost is 30 percent. That number is only an example, so pick your own. Suggested price is £1.54 divided by 0.30, which is £5.13. You round up to £5.50, and the real food cost on that price is £1.54 divided by £5.50, exactly 28 percent.

Turn the example into tests

This is how you stop trusting the AI and start checking it. Enter the five ingredients and the recipe above, then confirm the app shows:

  • Basil line cost of £0.40, not £0.20.

  • Recipe cost of £1.54.

  • Suggested price of £5.13 before rounding.

  • Food cost of 28 percent at a £5.50 price.

Then change one input and re-check by hand: halve the basil yield to 25 percent and the line should double to £0.80, taking the recipe to £1.94. If any of these is off, tell the builder which number is wrong and what it should be. Generated code can look fine and still divide by the wrong value.

The prompt for your AI app builder

text
Build a recipe cost calculator with three tables: ingredients (name, purchase
price, pack size in grams or ml, usable yield percent), recipes (name,
portions, target food cost percent) and recipe lines (recipe, ingredient,
quantity in grams or ml).
Compute line cost as quantity / (yield / 100) * (price / pack size).
Show recipe cost, cost per portion, suggested price (cost per portion /
target food cost) and the real food cost percent at a price I type in.
Store all quantities in grams or ml. Round money to two decimals only when
displaying, never in the calculation.

The last sentence matters: rounding each line early makes small errors that add up across a big menu.

What to build next

Once the basics work, add the features that save real time: updating one ingredient price and seeing every affected recipe change, and a list of recipes sorted by food cost percentage so the worst margins are obvious. For the menu itself, planning a weekly specials menu with AI pairs well with accurate costs, and a QR code menu for a restaurant puts the prices in front of customers. If you keep supplier invoices on paper, reading receipts and invoices with AI can feed the ingredient prices. The same pattern of inputs, formulas and a rounded output drives a quote calculator, and the broader approach is in how to build an app with AI. For where AI helps and where it does not in a small business, start at AI for small business.

Recipe cost calculator FAQ

How do you calculate recipe cost per portion?

Add up the cost of every ingredient used, adjusting for usable yield, then divide by the number of portions the recipe makes.

What food cost percentage should I aim for?

It depends on your business and margins, so set your own target. The calculation is the same whatever number you choose: price equals cost per portion divided by the target.

What is yield in recipe costing?

The share of a purchased ingredient you can actually use after trimming, peeling or coring. Divide the amount you use by the yield to find how much you have to buy.

Can I build a recipe cost calculator without coding?

Yes, with an AI app builder, as long as you describe the tables and formulas precisely and check the output against a hand-worked example like the one above.

How did this land?

About the author

Manuele Estivo
Manuele Estivo

Growth & SEO Lead

Manuele covers distribution: SEO, content strategy, and how AI-built products find their first thousand users. He tests everything he recommends.

Share

Get the next post in your inbox

One email a month. Product updates, engineering posts, and the best of Built with Swarmz.

I agree to receive emails about AI building tips and Swarmz product news. Unsubscribe any time.