# Calculate total size when CID is a directory

**URL:** <https://discuss.ipfs.tech/t/calculate-total-size-when-cid-is-a-directory/19832>\
**Category:** Help\
**Tags:** files\
**Created:** [October 15, 2025, 11:22am UTC](https://discuss.ipfs.tech/t/calculate-total-size-when-cid-is-a-directory/19832 "2025-10-15T11:22:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![0xmichalis](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/0xmichalis/32/9525_2.png) [@0xmichalis](https://discuss.ipfs.tech/u/0xmichalis)\
**Post date:** [October 15, 2025, 11:22am UTC](https://discuss.ipfs.tech/t/calculate-total-size-when-cid-is-a-directory/19832/1 "2025-10-15T11:22:53Z")

</div>

Hi folks, what is the best way to estimate directory sizes when a client has access only to a gateway and not a node? I figured that for files I could just send a HEAD and retrieve the size via Content-Length but for directories it does not look straightforward. It seems that the total size is part of the HTML response that is returned by the gateway but I was wondering whether gateways expose this via the API.

---

<div class="post-metadata">

**Author:** ![robin](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/robin/32/7938_2.png) [@robin](https://discuss.ipfs.tech/u/robin)\
**Post date:** [October 30, 2025, 2:21pm UTC](https://discuss.ipfs.tech/t/calculate-total-size-when-cid-is-a-directory/19832/2 "2025-10-30T14:21:35Z")

</div>

Hi @0xmichalis,

there isn’t an obvious way to do this in a more HTTP-native way currently. You could parse out the HTML, though I don’t think there’s any guarantee that all gateways will support this. Alternatively you could walk the tree, though I assume you’d rather not.

If you would like to see it added, please look at [IPIPs](https://specs.ipfs.tech/meta/ipip-process/)!
