<p>For one, there is no JSON block format - different APIs have different ways of interpreting and displaying a block in a JSON response, and none of them will ever match the block size.</p>

<p>Your mistake appears to be saving the actual hex block as text. </p>

<pre><code>1996396 = 2 * 998198
</code></pre>

<p>You must write the data as an actual binary file. i.e., write <code>12</code> as the byte <code>0x12</code>, instead of saving the text "12" directly, which will write the bytes <code>0x3132</code> to disk, doubling the size of the file saved. Saving it as text will double the file size, as you've noticed already.</p>

CC BY-SA 4.0
2020-02-26T17:23:19.637Z
Yeah. Seems about right. Thanks!!
wowfactory
CC BY-SA 4.0
2020-02-25T12:02:33.493Z
2020-02-25T12:02:33.493Z
Raghav Sood
<p>I am trying to download a block(Height:474044) using an API from <a href="https://blockchain.info/block-height/474044?format=json" rel="nofollow noreferrer">here</a> in python. Block is obviously downloaded in JSON format. But when I store it in a file on my system it shows very weird size number, not matching with actual blocksize on network. I also tried to download data in hex format using <a href="https://blockchain.info/block/000000000000000000ff265a641721e79bbc559d8b0e4894332732109f1a3383?format=hex" rel="nofollow noreferrer">this link</a>. But still, when I try to store it in a file(JSON/Text), It is not showing the size same as shown in block details officially. I have intentionally chosen a block before segwit BIP to avoid any further confusion. Help me to confirm my downloaded blocksize with actually mentioned on network. This question might seem naive to some users as I am new to bitcoin. Thanks for help in advance. </p>

CC BY-SA 4.0
2020-02-25T11:38:32.453Z
What size do you see?
Raghav Sood
CC BY-SA 4.0
2020-02-25T11:57:46.293Z
Actual Block Size=998198, JSON File Size Stored on My System=5866321, Binary File Size Stored on My System=1996396. All sizes are in bytes.
wowfactory
<block><python><blocksize>
Why downloaded Block Size doesn't match with actual block size mentioned on network?
wowfactory
# Why downloaded Block Size doesn't match with actual block size mentioned on network?

(Asked by: username_0 on 2020-02-25)

I am trying to download a block(Height:474044) using an API from [here](https://blockchain.info/block-height/474044?format=json) in python. Block is obviously downloaded in JSON format. But when I store it in a file on my system it shows very weird size number, not matching with actual blocksize on network. I also tried to download data in hex format using [this link](https://blockchain.info/block/000000000000000000ff265a641721e79bbc559d8b0e4894332732109f1a3383?format=hex). But still, when I try to store it in a file(JSON/Text), It is not showing the size same as shown in block details officially. I have intentionally chosen a block before segwit BIP to avoid any further confusion. Help me to confirm my downloaded blocksize with actually mentioned on network. This question might seem naive to some users as I am new to bitcoin. Thanks for help in advance.

**Tags:** block, python, blocksize

> **Comments:**
> **username_1**: What size do you see?  
> **username_0**: Actual Block Size=998198, JSON File Size Stored on My System=5866321, Binary File Size Stored on My System=1996396. All sizes are in bytes.  

---

## 1 answers

### Answer by username_1 on 2020-02-25. Score: 1 | Accepted answer

For one, there is no JSON block format - different APIs have different ways of interpreting and displaying a block in a JSON response, and none of them will ever match the block size.

Your mistake appears to be saving the actual hex block as text.

```
1996396 = 2 * 998198

```

You must write the data as an actual binary file. i.e., write `12` as the byte `0x12`, instead of saving the text "12" directly, which will write the bytes `0x3132` to disk, doubling the size of the file saved. Saving it as text will double the file size, as you've noticed already.

> **Comments:**
> **username_0**: Yeah. Seems about right. Thanks!!  

---

