Skip to content

Instantly share code, notes, and snippets.

@reimabenson
reimabenson / shopify-money-format-utils.ts
Last active October 29, 2025 03:15
Shopify Money Format Utils (Maintained 2025) - Format & parse money like Shopify Liquid (multi-currency, locale-aware, ICU-safe).
// add once near the top
const normalizeLocaleArtifacts = (s: string) =>
s
// normalize various non-breaking / narrow spaces to regular space
.replace(/\u00A0|\u202F/g, ' ')
// normalize typographic apostrophe ’ to ASCII '
.replace(/\u2019/g, "'");
export function formatMoney(value: number | string, format: string = 'amount', options: { symbol?: string; position?: string } = {}): string {
if (typeof format === 'string') format = format.trim().toLowerCase();