---
title: How to Calculate Account Creation Cost
description:
  "Every time you create an account, that creation costs an amount of SOL. Learn
  how to calculate how much an account costs at creation."
---

Keeping accounts alive on Solana incurs a data storage cost called
[rent](/docs/core/accounts/account-structure). For the calculation, you need to
consider the amount of data you intend to store in the account. Rent can be
reclaimed in full if the account is closed.

<CodeTabs storage="cookbook" flags="r">

```ts !! title="Kit" file=packages/docs-examples/cookbook/accounts/calculate-rent/kit.ts#region=calc highlight=6

```

```ts !! title="Legacy" file=packages/docs-examples/cookbook/accounts/calculate-rent/legacy.ts#region=calc highlight=7

```

```rust !! title="Rust" file=packages/docs-examples/cookbook/accounts/calculate-rent/rust/src/main.rs#region=calc

```

```py !! title="Python"
import asyncio
from solana.rpc.async_api import AsyncClient

async def main():
    rpc = AsyncClient("http://localhost:8899")

    space = 1500  # bytes

    async with rpc:
        lamports = await rpc.get_minimum_balance_for_rent_exemption(space)
        print(f"Minimum balance for rent exemption: {lamports.value}")
        print(f"For account size: {space} bytes")
        print(f"Cost in SOL: {lamports.value / 1_000_000_000}")

if __name__ == "__main__":
    asyncio.run(main())
```

</CodeTabs>
