# How can you determine size of table

**URL:** <https://discourse.nodered.org/t/how-can-you-determine-size-of-table/77461>\
**Category:** General\
**Tags:** function-node\
**Created:** [11 April 2023 15:37 UTC](https://discourse.nodered.org/t/how-can-you-determine-size-of-table/77461 "2023-04-11T15:37:16Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fathi2022](https://avatars.discourse-cdn.com/v4/letter/f/b487fb/32.png) [@Fathi2022](https://discourse.nodered.org/u/Fathi2022)\
**Post date:** [11 April 2023 15:37 UTC](https://discourse.nodered.org/t/how-can-you-determine-size-of-table/77461/1 "2023-04-11T15:37:16Z")

</div>

Determine size of table

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [11 April 2023 15:40 UTC](https://discourse.nodered.org/t/how-can-you-determine-size-of-table/77461/2 "2023-04-11T15:40:04Z")

</div>

Are you developing a custom Node for Node RED?  
I'll assume your not - so I will move it out of **Developing Nodes**

And if you want help, please provide more then 4 words

> Determine size of table

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [11 April 2023 16:44 UTC](https://discourse.nodered.org/t/how-can-you-determine-size-of-table/77461/3 "2023-04-11T16:44:00Z")

</div>

I usually use a tape measure 😉

What kind of table. So you want the count of rows? Where is this table - on a web page?

Show us the debug msg

---

<div class="post-metadata">

**Author:** ![Fathi2022](https://avatars.discourse-cdn.com/v4/letter/f/b487fb/32.png) [@Fathi2022](https://discourse.nodered.org/u/Fathi2022)\
**Post date:** [14 April 2023 11:29 UTC](https://discourse.nodered.org/t/how-can-you-determine-size-of-table/77461/4 "2023-04-14T11:29:10Z")

</div>

Hi Stephen,

I have a table to display the components from the XML file.

so, I need to determine the size of the table after putting data on it.  
my regards

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [14 April 2023 11:31 UTC](https://discourse.nodered.org/t/how-can-you-determine-size-of-table/77461/5 "2023-04-14T11:31:36Z")

</div>

> [@Fathi2022](#):
>
> I have a table to display

A html table?

Are you using node-red dashboard?

> [@Fathi2022](#):
>
> so, I need to determine the size of the table after putting data on it

Size on screen? Count of rows?

---

<div class="post-metadata">

**Author:** ![Fathi2022](https://avatars.discourse-cdn.com/v4/letter/f/b487fb/32.png) [@Fathi2022](https://discourse.nodered.org/u/Fathi2022)\
**Post date:** [14 April 2023 11:45 UTC](https://discourse.nodered.org/t/how-can-you-determine-size-of-table/77461/6 "2023-04-14T11:45:28Z")

</div>

Yes, I am using the Node-Red dashboard.  
I need the size of the data on it. size of data in Bytes  
I can show you the table and discuss it if you do not mind over Zoom

> ![](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.nodered.org/steve-mcl/45/4826_2.png "Steve-Mcl") | [Steve-Mcl](https://discourse.nodered.org/u/steve-mcl)  
> 14 April |
> 
> - | - |

> ![](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/0/6076b81d5fc29cf9cbcdbc116c59868c0c80f3f2.png)Fathi2022:
> 
> I have a table to display

A html table?

Are you using node-red dashboard?

> ![](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/0/6076b81d5fc29cf9cbcdbc116c59868c0c80f3f2.png)Fathi2022:
> 
> so, I need to determine the size of the table after putting data on it

Size on screen? Count of rows?

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [14 April 2023 11:55 UTC](https://discourse.nodered.org/t/how-can-you-determine-size-of-table/77461/7 "2023-04-14T11:55:54Z")

</div>

> [@Fathi2022](#):
>
> size of data in Bytes

The size of the data in bytes is not related to Dashboard. You need to measure the input not how it translates to HTML - unless you have some issues with client browsers and want to try and identify how much memory the table is using in the browser.

I'm afraid your requirement isn't clear.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [14 April 2023 12:07 UTC](https://discourse.nodered.org/t/how-can-you-determine-size-of-table/77461/8 "2023-04-14T12:07:36Z")

</div>

I'm sorry, I can still not fully understand what you want.

For example, the "size" (in bytes) is still not clear - especially as you talk about dashboards and tables.  
I mean, do you want the size of all HTML elements the table creates? OR just the size (in bytes) of the data values?

NOTE: If you simply mean you would like to know the size of the payload (data) before you send it to the dashboard, then you can do that in a function node using something like this [sizeOf](https://www.npmjs.com/package/object-sizeof) library in a function node to measure the payload.

If you actually need to know the size at client side, then The Google Chrome Heap Profiler allows you to inspect object memory use.

---

<div class="post-metadata">

**Author:** ![Fathi2022](https://avatars.discourse-cdn.com/v4/letter/f/b487fb/32.png) [@Fathi2022](https://discourse.nodered.org/u/Fathi2022)\
**Post date:** [17 April 2023 14:44 UTC](https://discourse.nodered.org/t/how-can-you-determine-size-of-table/77461/9 "2023-04-17T14:44:43Z")

</div>

I have 2 experiments so I need to check the size of both tables to compare them with each other.

---

<div class="post-metadata">

**Author:** ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)\
**Post date:** [17 April 2023 15:37 UTC](https://discourse.nodered.org/t/how-can-you-determine-size-of-table/77461/10 "2023-04-17T15:37:42Z")

</div>

You are not really providing much information to allow people to help you.

Can you provide more details, examples of your data etc ?

If your tables come from 2 xml files it sounds like you would do better to compare the 2 files ?

---

<div class="post-metadata">

**Author:** ![Fathi2022](https://avatars.discourse-cdn.com/v4/letter/f/b487fb/32.png) [@Fathi2022](https://discourse.nodered.org/u/Fathi2022)\
**Post date:** [17 April 2023 16:06 UTC](https://discourse.nodered.org/t/how-can-you-determine-size-of-table/77461/11 "2023-04-17T16:06:03Z")

</div>

In the first experiment, I convert XML to JSON to read data and save it in a Table by using Node-Red so I want here to determine the size of the Table.Honestly,

 ![20230417_170253](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/e/8e2d4062537a2e6ef8f57047a3fef861a28547cd.jpeg)  
I got the result but I am not quite sure is true.

---

<div class="post-metadata">

**Author:** ![Fathi2022](https://avatars.discourse-cdn.com/v4/letter/f/b487fb/32.png) [@Fathi2022](https://discourse.nodered.org/u/Fathi2022)\
**Post date:** [17 April 2023 16:09 UTC](https://discourse.nodered.org/t/how-can-you-determine-size-of-table/77461/12 "2023-04-17T16:09:12Z")

</div>

![20230417_170716](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/f/df8869edaa2ddc91233ec900d468071f7c9e96f9.jpeg)

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [17 April 2023 17:05 UTC](https://discourse.nodered.org/t/how-can-you-determine-size-of-table/77461/13 "2023-04-17T17:05:26Z")

</div>

> [@Fathi2022](#):
>
> I got the result but I am not quite sure is true.

Test your method with some data that you do know the size of.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [17 April 2023 17:16 UTC](https://discourse.nodered.org/t/how-can-you-determine-size-of-table/77461/14 "2023-04-17T17:16:31Z")

</div>

> [@Fathi2022](#):
>
> I got the result but I am not quite sure is true.

But what do you mean by "true"? That method is certainly accurately measuring A size but do you understand what you've created?

If all you want is a rough comparison then that method should be fine. But because you've converted the JSON to a string, you will have added some size to it and might even have lost data since not everything can be stringified from a JavaScript object.

---

<div class="post-metadata">

**Author:** ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)\
**Post date:** [17 April 2023 17:18 UTC](https://discourse.nodered.org/t/how-can-you-determine-size-of-table/77461/15 "2023-04-17T17:18:17Z")

</div>

I see a line in your function that doesn't seem correct ?

```auto
//Convert the size to Kilobytes
var sizeInKB = sizeInBytes

```

Perhaps this would be better ?

```auto
//Convert the size to Kilobytes
var sizeInKB = sizeInBytes/1024

```

---

<div class="post-metadata">

**Author:** ![Fathi2022](https://avatars.discourse-cdn.com/v4/letter/f/b487fb/32.png) [@Fathi2022](https://discourse.nodered.org/u/Fathi2022)\
**Post date:** [17 April 2023 17:19 UTC](https://discourse.nodered.org/t/how-can-you-determine-size-of-table/77461/16 "2023-04-17T17:19:31Z")

</div>

which line mate?

---

<div class="post-metadata">

**Author:** ![Fathi2022](https://avatars.discourse-cdn.com/v4/letter/f/b487fb/32.png) [@Fathi2022](https://discourse.nodered.org/u/Fathi2022)\
**Post date:** [17 April 2023 17:26 UTC](https://discourse.nodered.org/t/how-can-you-determine-size-of-table/77461/17 "2023-04-17T17:26:48Z")

</div>

the function of the second experiment is to get the size of the table as follows:

long size = System.Text.Encoding.UTF8.GetByteCount(strSelectedComponentStream);  
double sizeInByte = size;  
labSizeFile.Text = sizeInByte.ToString() + "Bytes";

---

<div class="post-metadata">

**Author:** ![Fathi2022](https://avatars.discourse-cdn.com/v4/letter/f/b487fb/32.png) [@Fathi2022](https://discourse.nodered.org/u/Fathi2022)\
**Post date:** [17 April 2023 17:32 UTC](https://discourse.nodered.org/t/how-can-you-determine-size-of-table/77461/18 "2023-04-17T17:32:16Z")

</div>

Yes, you are right mate when I determine the size of the table gives me a big result So how can I determine the size of the table without converting JSON to string ?

---

<div class="post-metadata">

**Author:** ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)\
**Post date:** [17 April 2023 17:34 UTC](https://discourse.nodered.org/t/how-can-you-determine-size-of-table/77461/19 "2023-04-17T17:34:35Z")

</div>

In order to make code readable and usable it is necessary to surround your code with three backticks (also known as a left quote or backquote `````)

````auto
``` 
   code goes here 
```

````

You can edit and correct your post by clicking the pencil ✏ icon.

See this post for more details - [How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506)

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [17 April 2023 19:30 UTC](https://discourse.nodered.org/t/how-can-you-determine-size-of-table/77461/20 "2023-04-17T19:30:52Z")

</div>

> [@Fathi2022](#):
>
> So how can I determine the size of the table without converting JSON to string ?

Some quick searching turned up this:

[object-sizeof - npm (npmjs.com)](https://www.npmjs.com/package/object-sizeof)

But I see that Steve already mentioned it.

The only alternative I can come up with would be to create a web page, feed your data into a JS variable on it and write it to localStorage, measuring the remaining free storage before and after.

[Next page](https://discourse.nodered.org/t/how-can-you-determine-size-of-table/77461.md?page=2)
