Short answer: stir 34 g of decyl glucoside and 38 g of cocamidopropyl betaine into 155 g of distilled water, add glycerin, a pinch of xanthan gum and a cosmetic preservative, then bring the pH down to about 5 with citric acid. That makes 8 fl oz (240 mL) of mild, sulfate-free shampoo in 20 minutes. Castile soap and baking soda recipes skip the pH step, and that is why they leave hair dull and tangled.
I make shampoo the way a cosmetic chemist would: by weight, with a pH strip in hand. Hair is a protein fiber with an electric charge, and the pH of the wash decides how rough that charge makes it. This guide gives three recipes, a calculator that scales them to your bottle and hair type, and the chemistry behind each step.
At a glance
What you need
- 155 g distilled water
- 34 g decyl glucoside
- 38 g cocamidopropyl betaine
- 5 g glycerin and 1 g xanthan gum
- 2.4 g cosmetic preservative, citric acid and pH strips
Steps
- Mix the xanthan gum into the glycerin.
- Stir the slurry into the water until it thickens.
- Stir in both surfactants slowly, without foaming.
- Add the preservative.
- Add citric acid by drops until the pH reads 5.
The one tool that matters
Measure by weight, not by spoon. Surfactants are thick and cling to measuring spoons, and a kitchen scale that reads 0.1 g makes the recipe repeatable. The calculator gives spoon measures only as a rough check.
This guide contains Amazon affiliate links. 33Science earns a commission on qualifying purchases. See our affiliate disclosure.
Homemade shampoo calculator
Choose a formula, a bottle size, your hair type and a preservative. The calculator lists every ingredient as a percentage and a weight, estimates the citric acid you will need and tells you how long the bottle lasts.
Homemade shampoo calculator
Pick a formula, a bottle size and your hair type. The calculator gives every ingredient by weight, the citric acid to start with, and how long the bottle lasts.
Weights assume decyl glucoside at 50% active, cocamidopropyl betaine at 30%, SLES liquid at 28% and a dose of about 7 g (1½ teaspoons) per wash. US measures are approximate; weigh on a scale that reads 0.1 g. The citric acid figure is a starting point: always finish by testing the pH.
To size a citric acid adjustment for a different batch, use the pH adjustment calculator.
Hair type sets the strength. An oily scalp gets 15% active surfactant, normal hair 12% and dry, curly or color-treated hair 9%. Less surfactant removes less of the sebum that keeps dry hair supple. The glucoside and betaine split stays fixed at 60:40 by active matter, a ratio that cleans well while staying mild.
Ingredients and tools

Decyl glucoside
Nonionic surfactant from corn sugar and coconut alcohol
14% of the batchThe main cleaner. Sold as a 50% solution. Its pH out of the bottle is around 12, so the batch needs acid.
Cocamidopropyl betaine
Amphoteric surfactant from coconut oil
16% of the batchBuilds foam and makes the anionic or nonionic cleaner gentler on skin and eyes. Sold as a 30% solution.
Glycerin
Glycerol, C3H8O3
2%A humectant that holds water on the hair and scalp. It also carries the xanthan gum so it disperses without lumps.
Xanthan gum
Polysaccharide from fermentation
0.4%Thickens glucoside shampoos, which salt does not thicken. Too much makes the shampoo stringy.
Citric acid
C6H8O7
About 0.6%, to pH 5Brings the pH down into the range hair tolerates. Dissolve it in an equal weight of water first.
Cosmetic preservative
For example benzyl alcohol, salicylic acid, sorbic acid
1%Required in any water-based shampoo you keep longer than a week. Choose one rated for rinse-off products and for your final pH.
Active matter
Each surfactant is sold diluted in water. A label of “30% active” means 100 g of the bottle carries 30 g of surfactant. Recipes that list the bottle weight without the active content cannot be compared; the calculator works in active matter and converts back to bottle weight.
Tools
- A digital scale that reads 0.1 g for the small ingredients
- pH test strips with a 4 to 7 range or a pH meter
- A glass beaker or heatproof jug, a silicone spatula and a small dropper bottle
- Nitrile gloves and glasses for handling concentrated surfactants
- A clean pump or squeeze bottle, rinsed with boiling water and dried
How to make sulfate-free shampoo
These amounts make 8 fl oz (240 mL) for normal hair. Use the calculator for other sizes and hair types. Work at room temperature; nothing in this recipe needs heat.

- Make the gum slurry. In a small cup, stir 1 g (about ¼ teaspoon) of xanthan gum into 5 g of glycerin until smooth. The glycerin wets each grain so it does not clump when it meets water.
- Thicken the water. Weigh 155 g of distilled water into a beaker. Stir in the slurry and keep stirring for two minutes. It turns slightly syrupy as the gum hydrates.
- Add the surfactants. Place the beaker on the scale and pour in 34 g of decyl glucoside, then 38 g of cocamidopropyl betaine. Stir slowly with a spatula. A whisk or a fast spoon makes foam that takes hours to settle.
- Add the preservative. Stir in 2.4 g of preservative. Check its data sheet for the dose and the pH range it covers.
- Adjust the pH. Dissolve 2 g of citric acid in 2 g of warm water. Add it a few drops at a time, stirring and testing, until a strip reads 5. Expect to use most of it, because decyl glucoside is strongly alkaline.
- Bottle and label. Pour it into a clean bottle and write the date on it. Let the bubbles rise overnight.
Adjust the thickness
If the shampoo is too thin, stir in another 0.2% of xanthan gum as a glycerin slurry. If it is stringy, you added too much gum; dilute with a little water and a matching share of surfactant.
How to make classic shampoo with SLES
Most drugstore shampoos run on sodium laureth sulfate (SLES) with cocamidopropyl betaine. This version uses the same pair. It foams more than the sulfate-free recipe and thickens with plain salt. For 8 fl oz at 12% active:
- Mix the surfactants. Weigh 127 g of distilled water, then slowly stir in 71 g of 28% SLES and 28 g of 30% betaine.
- Add glycerin and preservative. Stir in 5 g of glycerin and 2.4 g of preservative.
- Set the pH. SLES and betaine sit close to neutral, so only a little citric acid is needed. Add the 50% solution by drops to pH 5 to 5.5.
- Thicken with salt. Dissolve 2.4 g of table salt in a spoon of the batch and stir it back in. Wait a minute. Repeat once if you want it thicker, and stop there.
Why salt thickens SLES
Sodium ions crowd the sulfate head groups together, so the spherical micelles grow into long, worm-like chains that tangle and thicken the liquid. Too much salt breaks the worms apart and the shampoo turns thin again. Glucosides have no charged head, which is why salt barely thickens the sulfate-free recipe.
Castile soap shampoo with a vinegar rinse
Castile soap is the most common homemade shampoo online and the most disappointing. It is true soap, with a pH near 9, and in hard water it leaves calcium soap on the hair as a waxy, dull film. It works if you follow every wash with an acid rinse.
- Dilute the soap. Mix 2 parts liquid castile soap with 3 parts distilled water in a squeeze bottle. For 8 fl oz: 94 g soap, 137 g water and 5 g glycerin.
- Wash. Work 1 to 2 teaspoons into wet hair, mostly at the scalp, and rinse well.
- Rinse with acid. Mix apple cider vinegar 1:1 with water, the ratio Dr. Bronner’s recommends, and pour it through the hair. Leave it for a minute, then rinse lightly. Lemon juice works too, at 1 part juice to 2 parts water.
Rinse separately
Never mix vinegar or lemon juice into the soap bottle. Acid turns soap into free fatty acid, an oily layer that separates and stops cleaning. Keep the rinse in a separate cup.
Skip baking soda “no-poo” washes. A baking soda solution has a pH of about 8.3, which swells the cuticle and raises the negative charge on the fiber, and it removes almost no oil because it is not a surfactant.
How to test and adjust the pH
The pH step separates a shampoo from a bottle of diluted detergent. It takes five minutes.

- Dilute a sample. Stir 1 teaspoon of shampoo into 9 teaspoons of distilled water. Strips read clearly in the thinner liquid, and a 10% solution is how formulators report shampoo pH.
- Dip and compare. Dip a strip for a second, wait 15 seconds and match the color against the chart in good light.
- Adjust. Above 5.5, add 5 drops of citric acid solution to the batch, stir for a minute and test again.
- Overshot? Below 4.5, add a few drops of a 10% baking soda solution, then test again.
| pH reading | What it means | Action |
|---|---|---|
| Above 7 | Glucoside alkalinity not neutralized, or a soap base | Add citric acid |
| 5.5 to 7 | Mild, but raises the charge on hair | Add a few more drops |
| 4.5 to 5.5 | Target range | Bottle it |
| Below 4.5 | Too acidic, may sting eyes | Add a little baking soda solution |
The science: how shampoo cleans hair
In three sentences
Shampoo surfactants lift sebum and dirt into micelles that rinse away. Hair is negatively charged above pH 3.7, and an alkaline wash raises that charge, which makes strands repel, rub and frizz. An acidic shampoo keeps the charge low and the cuticle flat.
What shampoo removes
Sebum, the oil from the glands at each hair follicle, is a mix of triglycerides and free fatty acids (about 57%), wax esters (26%), squalene (12%) and smaller amounts of cholesterol. It spreads along the hair shaft, collects dust and styling product, and turns hair limp. Water alone cannot lift it, because these molecules are nonpolar and water molecules hold onto each other through hydrogen bonds.
Surfactants and micelles
A surfactant molecule has a hydrocarbon tail that dissolves in oil and a polar head that dissolves in water. On a greasy hair, the tails sink into the sebum and the heads face the water; rubbing breaks the film into droplets coated with heads. Above the critical micelle concentration, surfactant molecules also cluster into micelles with oily cores. For sodium dodecyl sulfate that threshold is about 8 millimoles per liter. A shampoo at 12% active surfactant is more than a hundred times above it, which is why one teaspoon still cleans after it is diluted in wet hair.
The three surfactant types in these recipes differ by their head group:
| Type | Example | Head group | What it does |
|---|---|---|---|
| Anionic | SLES | Sulfate, negative | Strong cleaning, big foam, can irritate alone |
| Nonionic | Decyl glucoside | Glucose, no charge | Mild cleaning, gentle, thickens poorly |
| Amphoteric | Cocamidopropyl betaine | Positive and negative | Boosts foam, reduces irritation of the others |
| Soap | Potassium oleate (castile) | Carboxylate, negative | Cleans well, fails in hard water and acid |
Betaine makes the mix gentler. Blends richer in betaine score lower on the zein test, a lab measure of how much protein a surfactant pulls out, which tracks skin irritation. Betaine molecules sit between the main surfactant’s molecules in shared micelles and leave fewer free ones to attack the skin.
Why pH matters for hair
Hair is made of keratin, a protein with both acidic (carboxyl) and basic (amino) side groups. At its isoelectric point, measured at about pH 3.7 (published values range from 2.5 to 4.5), the charges balance. Above it the carboxyl groups lose their hydrogen ions and the fiber carries a net negative charge:
Keratin–COOH → Keratin–COO− + H+
The higher the pH, the more negative the surface. Negatively charged strands repel each other, which shows as static and flyaways, and they drag against each other with more friction when you comb, which chips the cuticle scales. A 2014 study in the International Journal of Trichology measured 123 shampoos, found 62% above pH 5.5 and concluded that shampoo pH should not exceed 5.5 for this reason. Alkaline solutions also swell the fiber and lift the cuticle.
The outer lipid layer
The outermost surface of each cuticle cell carries a layer of 18-methyleicosanoic acid (18-MEA), a branched fatty acid bonded to the protein. It makes healthy hair water-repellent and smooth. Alkaline treatments such as bleach, perms and harsh soaps strip it, which is why damaged hair turns porous and tangles. A mild, acidic shampoo removes sebum and leaves this layer in place.
Hard water and soap
Calcium and magnesium ions each carry a charge of +2, so each binds two soap molecules into an insoluble salt:
2 RCOO− + Ca2+ → (RCOO)2Ca
That calcium soap is the waxy coating castile users describe. The vinegar rinse works because acetic acid dissolves it and lowers the pH of the hair surface at the same time. Synthetic surfactants such as SLES and glucosides do not form insoluble calcium salts, so they rinse clean in hard water.
Homemade vs store-bought shampoo

| Feature | Sulfate-free | Classic SLES | Castile + rinse | Store shampoo |
|---|---|---|---|---|
| Main surfactant | Decyl glucoside + betaine | SLES + betaine | Potassium soap | SLES or sulfate-free blend |
| pH | 5 (adjusted) | 5 to 5.5 (adjusted) | About 9 | 3.5 to 9; most above 5.5 |
| Foam | Moderate | High | Moderate, low in hard water | High |
| Hard water | Rinses clean | Rinses clean | Leaves film without rinse | Rinses clean |
| Conditioning | Glycerin only | Glycerin only | None | Silicones, cationic polymers |
| Shelf life | 3 months preserved | 3 months preserved | Two weeks | Years, factory sealed |
Store shampoos carry conditioning polymers such as polyquaternium-10 and guar hydroxypropyltrimonium chloride. These carry a positive charge, stick to the negative spots on damaged hair and stay behind after rinsing to cut friction. The homemade recipes leave them out, so follow with a conditioner if your hair tangles.
Want conditioning?
For a two-in-one, add 0.3% guar hydroxypropyltrimonium chloride to the sulfate-free recipe in place of part of the xanthan gum. Disperse it in the glycerin with the gum and keep the pH at 5.
Troubleshooting
| Problem | Cause | Fix |
|---|---|---|
| Hair feels waxy or heavy | Calcium soap from castile in hard water | Use the vinegar rinse or switch to a surfactant recipe. |
| Hair frizzy and tangled | pH too high | Test the pH; bring it to 5. |
| Shampoo watery | No thickener, or salt in a glucoside recipe | Add xanthan gum as a glycerin slurry. |
| Lumps or “fish eyes” | Xanthan gum added straight to water | Strain, and pre-mix the gum with glycerin next time. |
| Thick foam layer in the bottle | Stirred too fast | Leave overnight; stir slowly next time. |
| Scalp itchy or dry | Too much surfactant for your scalp | Drop to the 9% setting or wash less often. |
| Cloudy, smells sour, or spots | Microbial growth | Discard it. Use a preservative and sterilize the bottle. |
| Stings the eyes | pH too low or too high, or SLES | Keep pH 4.5 to 5.5; use the sulfate-free recipe. |
The mistake that matters
Do not skip the preservative to keep the recipe “natural” and then store the bottle in a warm shower. Water, surfactant and warmth grow bacteria such as Pseudomonas within days, and you rub it into your scalp. No preservative means a fridge and a one-week batch.
Safety
Before you start
- Protect your eyes. Concentrated decyl glucoside, SLES and betaine cause serious eye damage. Wear glasses while handling them and rinse with running water for 15 minutes after a splash.
- Wear gloves with concentrates. Undiluted surfactants dry and irritate skin; diluted shampoo does not.
- Use a cosmetic preservative at its stated dose. More is not safer: preservatives above their limit irritate skin.
- Patch test. Rub a little diluted shampoo on your inner arm and wait 48 hours before the first wash. Cocamidopropyl betaine and fragrance oils are known contact allergens.
- Go light on essential oils. Stay at 0.5% or less, and keep tea tree and citrus oils away from cats.
- Label it. A clear shampoo in a reused bottle can look like a drink to a child.
All three recipes are safe for septic systems at normal use. Decyl glucoside, betaine and SLES are readily biodegradable.
More practical science: browse all our everyday science how-tos, from household chemistry to experiments you can build at home.
Homemade soap shampoo leaves hair alkaline and tangle-prone. Follow it with our guide to how to make conditioner at home, which explains why a positively charged conditioner fixes that.
Frequently asked questions
Yes. Mix a mild surfactant such as decyl glucoside with cocamidopropyl betaine and distilled water, thicken it with xanthan gum, add a cosmetic preservative and adjust the pH to about 5 with citric acid.
Between 4.5 and 5.5. Hair carries a negative charge above about pH 3.7, and an alkaline shampoo raises that charge, which increases friction, frizz and cuticle damage.
Not on its own. Castile soap has a pH near 9 and forms calcium soap in hard water, which leaves hair dull and waxy. Follow it with an apple cider vinegar rinse, diluted 1:1 with water, if you use it.
No. Baking soda is alkaline, so it lifts the cuticle and raises the charge on the hair, and it is not a surfactant, so it removes little oil.
Yes, if you keep it longer than a week. Water-based shampoo grows bacteria and mold, so use a broad-spectrum cosmetic preservative or make small batches and refrigerate them.
About three months with a preservative and a clean bottle. Without one, keep it in the fridge and use it within a week.
Add xanthan gum pre-mixed in glycerin to a sulfate-free recipe. Shampoos made with SLES thicken with a small amount of salt, added a little at a time.
Decyl glucoside and coco glucoside are made from plant sugars and coconut fatty alcohol. Combined with cocamidopropyl betaine they clean well and are gentle on the scalp.
Either the surfactant level is too low for your scalp or calcium soap from castile soap is coating the hair. Raise the active surfactant to 15% or switch away from soap.
Yes, at 0.5% or less of the batch. Higher amounts irritate the scalp and some essential oils are common contact allergens.
Sources
- Gavazzoni Dias MF et al. The shampoo pH can affect the hair: myth or reality? International Journal of Trichology, 2014
- Gavazzoni Dias MF. Hair cosmetics: an overview. International Journal of Trichology, 2015
- PubChem. Sodium dodecyl sulfate
- Lisa Bronner. Skin health, pH and Dr. Bronner’s soap
- US Food and Drug Administration. Microbiological safety and cosmetics
- McMullen RL et al. Cationic polymers and the hair surface. International Journal of Cosmetic Science, 2021
- Fernandes C et al. Hair care: structure, damage and cosmetic treatment. Polymers, 2023
- Picardo M et al. Sebaceous gland lipids. Dermato-Endocrinology, 2009
- Cornwell PA. A review of shampoo surfactant technology. International Journal of Cosmetic Science, 2018
- Deckner G. Shampoo technology. UL Prospector
- PubChem. Sodium bicarbonate
- Dr. Bronner’s Help Center. How can I shampoo with Dr. Bronner’s products?
- BASF. Plantacare 2000 UP technical data sheet

