Polkadot Apps
    Preparing search index...

    Function formatBalance

    • Format a planck value for display with locale-aware thousand separators, decimal truncation, and an optional token symbol.

      Builds on formatPlanck for BigInt-safe conversion, then applies presentation formatting. Unlike formatPlanck, trailing .0 is omitted — display values show "1,000" not "1,000.0".

      Parameters

      • planck: bigint

        The raw planck value as a bigint. Must be non-negative.

      • Optionaloptions: FormatBalanceOptions

        Formatting options.

      Returns string

      A display-ready string (e.g. "1,000.5 DOT").

      If planck is negative or decimals is invalid (delegated to formatPlanck).

      import { formatBalance } from "@polkadot-apps/utils";

      formatBalance(10_000_000_000n); // "1"
      formatBalance(15_000_000_000n, { symbol: "DOT" }); // "1.5 DOT"
      formatBalance(10_000_000_000_000n, { symbol: "DOT" }); // "1,000 DOT"
      formatBalance(12_345_678_900n, { maxDecimals: 2 }); // "1.23"
      formatBalance(0n, { symbol: "DOT" }); // "0 DOT"