Shopify Money Format Helper
Preview a currency format, get its settings string, and copy a JavaScript port for anywhere Liquid can't reach.
Your details
JavaScript port of your currency format
// Formats a price exactly like your currency formatting setting does in Liquid
// (Settings → General → Store defaults → "Change currency formatting" in your Shopify admin).
// Style used here: "1,234.56" ({{amount}}).
//
// Call it with the price in the smallest unit of your currency (cents for USD), the same shape
// Shopify uses for product.price, cart.total_price and the AJAX cart API (cart.js).
function formatMoney(cents) {
var before = "$";
var after = "";
var noDecimals = false;
var thousands = ",";
var decimal = ".";
var value = Math.abs(cents) / 100;
var fixed = noDecimals ? Math.round(value).toString() : value.toFixed(2);
var parts = fixed.split(".");
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, thousands);
var amount = parts.length > 1 ? parts.join(decimal) : parts[0];
return (cents < 0 ? "-" : "") + before + amount + after;
}
// Example: formatMoney(123456) → "$1,234.56"This matches Shopify's built-in currency formatting, which controls the money filter in Liquid. It isn't a separate Liquid object you reference by name; set it once in the admin and every theme price uses it automatically.
Use this JS port anywhere Liquid can't reach: a cart drawer built with the AJAX API, a custom app, or a checkout UI extension.
Live preview
How Shopify formats currency
In your Shopify admin, go to Settings → General, open Store defaults, and click Change currency formatting. You pick a placeholder style built from {{amount}} and its variants, plus any symbol text before or after it. That setting controls every price the money filter prints in Liquid, storefront-wide.
| Placeholder | Example |
|---|---|
{{amount}} | 1,234.56 |
{{amount_no_decimals}} | 1,234 |
{{amount_with_comma_separator}} | 1.234,56 |
{{amount_no_decimals_with_comma_separator}} | 1.234 |
{{amount_with_space_separator}} | 1 234,56 |
{{amount_no_decimals_with_space_separator}} | 1 234 |
{{amount_with_apostrophe_separator}} | 1'234.56 |
{{amount_with_period_and_space_separator}} | 1 234.56 |
Default settings ("$" before, amount style)
- Price in cents
- 123456
"$1,234.56"
Where the JavaScript port helps
Liquid's money filter already handles this on the server. The JavaScript port is for places Liquid can't reach: a cart drawer built against the AJAX Cart API (cart.js), a custom app, or a checkout UI extension, all of which hand you prices as plain numbers in cents and expect you to format them yourself.
Questions people ask
Is money_format a Liquid object I can reference?
No, it's an admin setting, not something you read in Liquid directly. Set it once in Settings → General → Store defaults, and the money filter (and every theme price) follows it automatically.
Why does the function take cents, not dollars?
That's the shape Shopify itself uses everywhere: product.price, cart.total_price and the AJAX Cart API are all in the smallest unit of your currency (cents for USD), which is also what the Liquid money filter expects.
My currency doesn't use two decimal places. What do I change?
Pick one of the "no decimals" styles, which several currencies (like JPY and KRW) use by default in Shopify's own formatting options.
Does this handle multi-currency conversion?
No, this only formats a number you already have. For converting between currencies in Shopify Markets, Shopify handles the conversion server-side before your theme ever sees the price.
Related tools
Last reviewed 30 September 2026.
