Calculate your daily macronutrient needs effortlessly. Determine the optimal ratio of protein, carbohydrates, and fats based on your fitness goals and calorie intake.
AI Generation Prompt
Technical Specification: Professional Macro Nutrient Calculator
Overview
A high-performance, browser-based utility designed to calculate daily caloric needs and macronutrient distribution (Protein, Carbohydrates, Fats). The interface is optimized for speed, clarity, and ease of use, providing instant feedback as users adjust inputs.
Core Features
- Dynamic TDEE Engine: Real-time calculation of daily calorie needs using the Mifflin-St Jeor Equation.
- Interactive Macro Sliders: Range inputs that allow users to fine-tune the percentage of calories derived from protein, carbs, and fats.
- Visual Data Breakdown: A clean, responsive SVG-based donut chart (or CSS-conic gradient) displaying the macro split.
- Dietary Goal Presets: Quick-select buttons for 'Cutting', 'Maintenance', and 'Bulking' to auto-populate calorie targets.
- In-Memory Calculation: Zero persistence; the app respects user privacy by operating strictly in-memory.
UI/UX Design
- Color Palette: A clean, light-mode palette:
#ffffff(Background),#f8fafc(Section backgrounds),#334155(Text),#0ea5e9(Primary Accent), and#10b981(Success Green). - Typography: Modern sans-serif stack (Inter/system-ui).
- Animations: Subtle
transition-allon input changes. Smooth opacity shifts when switching between result views. - Responsiveness: Mobile-first design. Stacked layout on screens < 768px; side-by-side dashboard layout on larger screens.
Development Constraints (Strict)
- Single File: All HTML, CSS (via CDN), and Vanilla JS must reside in one file.
- No Storage: Absolutely NO
localStorage,sessionStorage, or cookies. The app must be compatible with a sandboxed iframe with storage disabled. - No External Dependencies: Do not use frameworks like React/Vue. Use Vanilla JS and Tailwind CSS via CDN.
- No Popups: Replace native
alert()orprompt()with custom CSS-based modal overlays. - Security: Ensure all links use
target="_blank" rel="noopener noreferrer".
Implementation Steps
- Setup: Initialize a Tailwind CSS environment for rapid styling.
- State Management: Create a JS object to store user inputs (age, weight, height, activity level, goal).
- Calculation Logic:
- Create a helper function to calculate BMR.
- Calculate TDEE based on the activity multiplier.
- Calculate macronutrient grams: (Calories * % / MacroCaloriesPerGram).
- Rendering: Create an update function that triggers on any input change, re-rendering the results and the visual charts without page refresh.
- Validation: Add robust input sanitization to ensure numerical inputs are positive and within physiological norms.
Spread the word
Files being used
Frequently Asked Questions
Everything you need to know about using this application.
How does this macro calculator work?
This tool uses the Mifflin-St Jeor equation to calculate your Basal Metabolic Rate (BMR) and Total Daily Energy Expenditure (TDEE), then distributes your target calories into optimized protein, fat, and carbohydrate ratios.
Can I use this for keto or high-protein diets?
Yes. The calculator features interactive sliders that allow you to manually adjust the percentage breakdown of each macronutrient to support specific dietary protocols like keto, high-protein, or low-carb.
Is my fitness data saved to your server?
No. This tool is a client-side application. No data is stored, saved, or transmitted to any server. Once the page is closed or refreshed, all input data is cleared for your privacy.



