Parity Purchasing Power Price Web Component Demo

A small structural-only zero-dependency Web Component to show Parity Purchasing Power normalized prices. Inspired by the Wes Bos blog post.

Return to the source code on GitHub.

Please note that this is not a currency converter (you will get the same currency out that you put in). It transforms the number value with a parity purchasing ratio to normalize that cost to a new price for a specified country. Outputs use the Intl.NumberFormat API to properly format localized currency values.

This (optionally) works with CloudCannon’s Geolocation feature to automatically detect the visitor’s country.

Implicit Currency

Currency is parsed from three letter code in text content. Read more about currency-display options.

From Input To Output Note
US πŸ‡ΊπŸ‡Έ USD $10 GB πŸ‡¬πŸ‡§ $10 USD
FR πŸ‡«πŸ‡· EUR 10 € DE πŸ‡©πŸ‡ͺ 10 € EUR
FR πŸ‡«πŸ‡· EUR 20 € DE πŸ‡©πŸ‡ͺ 20 € EUR
FR πŸ‡«πŸ‡· EUR 100 € DE πŸ‡©πŸ‡ͺ 100 € EUR
US πŸ‡ΊπŸ‡Έ USD $100 UY πŸ‡ΊπŸ‡Ύ $100 USD
US πŸ‡ΊπŸ‡Έ USD $10 GB πŸ‡¬πŸ‡§ $10 USD extra text that is stripped Extra text is stripped.
GB πŸ‡¬πŸ‡§ GBP Β£10 US πŸ‡ΊπŸ‡Έ Β£10 GBP
US πŸ‡ΊπŸ‡Έ $10 USD GB πŸ‡¬πŸ‡§ $10 USD Input value has currency as a suffix
US πŸ‡ΊπŸ‡Έ $4.00 USD GB πŸ‡¬πŸ‡§ $4.00 USD With currency-display="code"

Explicit Currency

Currency code is specified in currency attribute. Read more about currency-display options.

From Input To Output Note
GB πŸ‡¬πŸ‡§ Β£10 US πŸ‡ΊπŸ‡Έ Β£10 With currency="GBP"
GB πŸ‡¬πŸ‡§ Β£10 US πŸ‡ΊπŸ‡Έ Β£10 With currency="GBP" currency-display="code"
CA πŸ‡¨πŸ‡¦ $4.00 NZ πŸ‡³πŸ‡Ώ $4.00 With currency="CAD"
CA πŸ‡¨πŸ‡¦ $4.00 NZ πŸ‡³πŸ‡Ώ $4.00 With currency="CAD" currency-display="code"

Using Geolocation

(Optional) The country code is provided for the visitor automatically using CloudCannon’s Geolocation feature.

From Input To Output Note
GB πŸ‡¬πŸ‡§ GBP Β£6.77 Unknown Β£6.77 GBP Implicit
CA πŸ‡¨πŸ‡¦ 4.00 Unknown 4.00 Implicit, with currency="CAD"
FR πŸ‡«πŸ‡· EUR 4 € Unknown 4 € EUR Implicit
DE πŸ‡©πŸ‡ͺ EUR 4 € Unknown 4 € EUR Implicit
US πŸ‡ΊπŸ‡Έ USD $4.00 Unknown $4.00 USD Implicit
US πŸ‡ΊπŸ‡Έ USD $4.00 Unknown $4.00 USD With explicit to="auto"