> ## Documentation Index
> Fetch the complete documentation index at: https://solana.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> This page is part of the Solana developer documentation at https://solana.com/developers/docs. Append `.md` to any docs URL, or send `Accept: text/markdown`, to get the page as Markdown.
> Index of all pages: https://solana.com/llms.txt. Per-section indexes such as https://solana.com/developers/docs/payments/llms.txt are smaller; prefer them when working on one task.
> Coding agents: install the official Solana skill for current APIs and conventions with `npx skills add https://github.com/solana-foundation/solana-dev-skill` (also served at https://solana.com/SKILL.md).
> Code in the cookbook and task pages comes from tested example files. Prefer it over writing API calls from memory.

# How to Calculate Account Creation Cost

> 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](/developers/docs/core/rent). 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.

<Tabs>
<Tab title="Kit">
<div className="sol-tab-label">Kit</div>

```ts highlight={6}
import { createSolanaRpc } from "@solana/kit";

const rpc = createSolanaRpc("http://localhost:8899");

const space = 1500n; // bytes
const lamports = await rpc.getMinimumBalanceForRentExemption(space).send();
console.log("Minimum balance for rent exemption:", lamports);
```

<div className="sol-run" data-run="cookbook/accounts/calculate-rent/calc" data-tab="Kit">
<div className="sol-run-bar"><button type="button" className="sol-run-btn">Run</button><span className="sol-run-note">Output from a local Surfpool network</span></div>
<div className="sol-run-out">

```text Output
Minimum balance for rent exemption: 11330880n
```

</div>
</div>

</Tab>
<Tab title="Web3.js v3">
<div className="sol-tab-label">Web3.js v3</div>

```ts highlight={7}
import { Connection } from "@solana/web3.js";

const connection = new Connection("http://localhost:8899", "confirmed");

// allocate 1.5k bytes of extra space in the account for data
const space = 1500;
const lamports = await connection.getMinimumBalanceForRentExemption(space);
console.log("Minimum balance for rent exemption:", lamports);
```

<div className="sol-run" data-run="cookbook/accounts/calculate-rent/calc" data-tab="Web3.js v3">
<div className="sol-run-bar"><button type="button" className="sol-run-btn">Run</button><span className="sol-run-note">Output from a local Surfpool network</span></div>
<div className="sol-run-out">

```text Output
Minimum balance for rent exemption: 11330880n
```

</div>
</div>

</Tab>
<Tab title="Rust">
<div className="sol-tab-label">Rust</div>

```rust
use solana_client::nonblocking::rpc_client::RpcClient;
use solana_commitment_config::CommitmentConfig;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let client = RpcClient::new_with_commitment(
        String::from("http://localhost:8899"),
        CommitmentConfig::confirmed(),
    );

    let data_len = 1500;
    let rent_exemption_amount = client
        .get_minimum_balance_for_rent_exemption(data_len)
        .await?;

    println!("{rent_exemption_amount}");

    Ok(())
}
```

<div className="sol-run" data-run="cookbook/accounts/calculate-rent/calc" data-tab="Rust">
<div className="sol-run-bar"><button type="button" className="sol-run-btn">Run</button><span className="sol-run-note">Output from a local Surfpool network</span></div>
<div className="sol-run-out">

```text Output
11330880
```

</div>
</div>

</Tab>
<Tab title="Python">
<div className="sol-tab-label">Python</div>

```py
import asyncio

from solana.rpc.async_api import AsyncClient
from solana.rpc.commitment import Confirmed


async def main():
    async with AsyncClient("http://localhost:8899", commitment=Confirmed) as client:
        space = 1500  # bytes
        lamports = (await client.get_minimum_balance_for_rent_exemption(space)).value
        print("Minimum balance for rent exemption:", lamports)


asyncio.run(main())
```

<div className="sol-run" data-run="cookbook/accounts/calculate-rent/calc" data-tab="Python">
<div className="sol-run-bar"><button type="button" className="sol-run-btn">Run</button><span className="sol-run-note">Output from a local Surfpool network</span></div>
<div className="sol-run-out">

```text Output
Minimum balance for rent exemption: 11330880
```

</div>
</div>

</Tab>
<Tab title="Go">
<div className="sol-tab-label">Go</div>

```go
package main

import (
	"context"
	"fmt"

	"github.com/solana-foundation/solana-go/v2/rpc"
)

func main() {
	client := rpc.New("http://localhost:8899")

	space := uint64(1500) // bytes
	lamports, err := client.GetMinimumBalanceForRentExemption(
		context.Background(), space, rpc.CommitmentConfirmed,
	)
	if err != nil {
		panic(err)
	}
	fmt.Println("Minimum balance for rent exemption:", lamports)
}
```

<div className="sol-run" data-run="cookbook/accounts/calculate-rent/calc" data-tab="Go">
<div className="sol-run-bar"><button type="button" className="sol-run-btn">Run</button><span className="sol-run-note">Output from a local Surfpool network</span></div>
<div className="sol-run-out">

```text Output
Minimum balance for rent exemption: 11330880
```

</div>
</div>

</Tab>
<Tab title="Web3.js (legacy)">
<div className="sol-tab-label">Web3.js (legacy)</div>

<Warning>
  **`@solana/web3.js` 1.x is no longer actively maintained**

  It receives critical fixes only. Use [Kit](/developers/docs/clients/official/javascript#solana-kit) for new code. To migrate existing code, follow the [Kit upgrade guide](https://www.solanakit.com/docs/upgrade-guide), or the [web3.js v3 migration guide](https://github.com/solana-foundation/solana-web3.js/blob/main/docs/web3js-v1-to-v3-migration.md) to keep the class-based API.

  To run this code, install 1.x with `npm install @solana/web3.js@1`. A plain `npm install @solana/web3.js` installs v3, which this code doesn't run on.
</Warning>

```ts highlight={7}
import { Connection } from "@solana/web3.js";

const connection = new Connection("http://localhost:8899", "confirmed");

// allocate 1.5k bytes of extra space in the account for data
const space = 1500;
const lamports = await connection.getMinimumBalanceForRentExemption(space);
console.log("Minimum balance for rent exemption:", lamports);
```

<div className="sol-run" data-run="cookbook/accounts/calculate-rent/calc" data-tab="Web3.js (legacy)">
<div className="sol-run-bar"><button type="button" className="sol-run-btn">Run</button><span className="sol-run-note">Output from a local Surfpool network</span></div>
<div className="sol-run-out">

```text Output
Minimum balance for rent exemption: 11330880
```

</div>
</div>

</Tab>
</Tabs>

<Note>
  The recorded output comes from a local Surfpool network, which still uses the
  older rate of 6,960 lamports per byte. Mainnet and devnet use 5,080 lamports
  per byte as of October 2026, so they return a lower value. See
  [rent](/developers/docs/core/rent).
</Note>
