
To convert gold price per ounce to gram, divide the price per troy ounce by 31.1035. At an illustrative price of 4,000 USD per troy ounce, that gives 128.61 USD per gram.
Use a troy ounce for gold
Gold prices use the troy ounce, which equals 31.1035 grams. An everyday avoirdupois ounce weighs 28.3495 grams. Using that everyday ounce gives the wrong result for a gold price quoted per troy ounce.
The conversion changes the weight unit. It does not change the currency or the time of the quote. A USD quote becomes a USD price per gram. A local-currency quote stays in that currency.
Price per gram = price per troy ounce ÷ 31.1035
Keep the unrounded result for further calculations. Round the amount when you display it.
Ounce to gram weight table
These are gold weights in troy ounces. The gram values are shown to four decimal places.
| Troy ounces | Grams |
|---|---|
| 1 oz | 31.1035 |
| 1/2 oz | 15.5518 |
| 1/4 oz | 7.7759 |
| 1/10 oz | 3.1104 |
This table converts weight, rather than price. For a price per gram, divide the full ounce price by 31.1035.
Price per gram of 22K, 21K and 18K
Start with the 24K price per gram, then adjust for karat:
Price per gram of a karat = 24K price per gram × karat ÷ 24
| Karat | Calculation | Purity |
|---|---|---|
| 22K | 24K price per gram × 22 ÷ 24 | 91.67% |
| 21K | 24K price per gram × 21 ÷ 24 | 87.5% |
| 18K | 24K price per gram × 18 ÷ 24 | 75% |
24K purity ranges from 99.9% to 100%. Keep weight conversion and purity adjustment as separate steps so you can check each calculation.
Convert grams to local gold units
One tola equals 11.6638 grams. Multiply the price per gram by 11.6638 to get a price per tola.
One lượng in Vietnam equals 37.5 grams. Multiply the price per gram by 37.5 for a price per lượng. For kilograms, one kilogram equals 32.1507 troy ounces.
Use a quote in the currency you want before applying these weight conversions.
Calculate it in JavaScript or Python
The spot endpoint works without an API key. Its JSON response gives the price as a string, in USD per troy ounce. These examples convert that value to a price per gram.
JavaScript
const response = await fetch( "https://api.goldprice.dev/v1/spot/XAU-USD-SPOT");if (response.ok === false) throw new Error("Spot request failed");const spot = await response.json();const usdPerGram = Number(spot.price) / 31.1035;console.log(usdPerGram);Python
Use Decimal with strings to preserve decimal input values during the calculation.
import jsonfrom decimal import Decimalfrom urllib.request import urlopenurl = "https://api.goldprice.dev/v1/spot/XAU-USD-SPOT"with urlopen(url) as response: spot = json.load(response)usd_per_gram = Decimal(spot["price"]) / Decimal("31.1035")print(usd_per_gram)The 4,000 USD example above is illustrative. For a fetched quote, check computed_at and is_stale alongside the price. Free data is 15 minutes late.
Use the gold converter, see gold prices by currency, or read the guide to gold weight units.
Live gold prices, historical OHLC, and multi-source aggregation, available via REST and SSE.