> For the complete documentation index, see [llms.txt](https://developer.paddle.com/llms.txt).

# Paddle.PricePreview()

Use to preview localized prices given location information supplied.

---

Use `Paddle.PricePreview()` to return a pricing preview object for the given items and location parameters.

[Pricing preview objects](https://developer.paddle.com/api-reference/pricing-preview/overview.md) hold calculated totals for prices, including discounts, taxes, and currency conversion. Typically used for [building pricing pages](https://developer.paddle.com/build/checkout/build-pricing-page.md). For more advanced pricing pages, consider the [`Paddle.TransactionPreview()`](https://developer.paddle.com/paddle-js/methods/paddle-transactionpreview.md) method instead.

Accepts the same request body as [the preview prices operation](https://developer.paddle.com/api-reference/pricing-preview/preview-prices.md) in the Paddle API, except fields must be formatted as `camelCase` rather than `snake_case`.

Returns a promise that contains an object that matches the response from the preview prices operation. Field names are `camelCase` rather than `snake_case`.

{% callout type="note" %}
When location information is omitted, Paddle.js automatically detects visitor location using their IP address and returns localized prices.
{% /callout %}

## Parameters

```yaml
title: Paddle.PricePreview() parameters
type: object
properties:
  request:
    type: object
    description: >-
      Pricing preview request body. Must include an `items` array. Include location information to return localized
      prices, or omit to let Paddle.js automatically detect location.
```

Check [the preview prices operation](https://developer.paddle.com/api-reference/pricing-preview/preview-prices.md) documentation to learn about the fields you can send in a request. Convert `snake_case` field names to `camelCase`, as is convention for JavaScript.

## Examples

This example includes a request with two items where the country code is the United States.

The request is passed to `Paddle.PricePreview()`, which returns a promise. It prints the response to the console.

{% tabs sync="paddlejs-preference" %}
{% tab-item title="Using a script tag" %}

```js
var request = {
  items: [
    {
      quantity: 1,
      priceId: "pri_01gsz8ntc6z7npqqp6j4ys0w1w",
    },
    {
      quantity: 1,
      priceId: "pri_01gsz8x8sawmvhz1pv30nge1ke",
    },
  ],
  address: {
    countryCode: "US",
  },
};

Paddle.PricePreview(request)
  .then((result) => {
    console.log(result);
  })
  .catch((error) => {
    console.error(error);
  });
```

{% /tab-item %}
{% tab-item title="Using a JavaScript package manager" %}

```ts
import { initializePaddle } from "@paddle/paddle-js";

const paddle = await initializePaddle({
  token: "live_7d279f61a3499fed520f7cd8c08",
});

const request = {
  items: [
    {
      quantity: 1,
      priceId: "pri_01gsz8ntc6z7npqqp6j4ys0w1w",
    },
    {
      quantity: 1,
      priceId: "pri_01gsz8x8sawmvhz1pv30nge1ke",
    },
  ],
  address: {
    countryCode: "US",
  },
};

paddle
  ?.PricePreview(request)
  .then((result) => {
    console.log(result);
  })
  .catch((error) => {
    console.error(error);
  });
```

{% /tab-item %}
{% /tabs %}

To learn more, see [Build a pricing page](https://developer.paddle.com/build/checkout/build-pricing-page.md)