Free Grams to Cups Widget
Put a working grams to cups converter on your recipe page with one line of HTML. 22 ingredients, no sign-up, no tracking, no dependencies, and it keeps working even if this site goes down.
Built for food bloggers who are tired of readers asking how many cups 250 grams is.
This is the actual widget, running on this page exactly as it would on yours.
Paste both lines wherever you want the converter to appear. The script tag only needs to be on the page once, however many widgets you add.
Both attributes are optional. Leave them off and the widget opens on all-purpose flour at 100 grams.
| Attribute | What it does | Example |
|---|---|---|
data-gramstocup | Marks the element as a widget. Required, no value needed. | <div data-gramstocup></div> |
data-ingredient | Which ingredient it opens on. Any slug from the dataset. | data-ingredient="butter" |
data-grams | Starting weight in grams. | data-grams="250" |
Valid ingredient slugs are listed in the density dataset, which is also downloadable as JSON and CSV if you would rather build your own.
The widget is most useful preset to the recipe it sits inside. A bread post that calls for 500 grams of flour can open the widget on flour at 500 grams, so a reader with only cups gets their answer without leaving the page or opening a second tab.
Every figure comes from the same published dataset as the rest of this site, with the source named for each ingredient. If a reader asks where the number came from, there is an answer.