Works on this device
API Payload Size Calculator
Paste a request or response body and see how many bytes it takes: as typed, as minified and pretty JSON, as Base64, and compressed with gzip in your browser. Add a bandwidth to see the time to send it. The body stays in this browser.
Enter your values
Check these values
Your values are worked out in this browser. They are not sent to a server.
Your result will show here
Fill in the values, then choose Calculate.
Your result
How it was worked out
How to use this calculator
- Choose what to measure: a body you paste, its gzip size, or a size you already know.
- Paste the body or open a file from your device. Choose whether it is JSON or any text.
- Type a bandwidth if you want the time to send it.
- Choose Calculate. The table compares every form with the body as typed.
How the sizes are worked out
- Bytes are counted in UTF-8, the encoding of JSON on the web. Plain letters and digits take 1 byte, letters such as é take 2, and most emoji take 4.
- Minified JSON has no white space outside strings. Pretty JSON has 2 spaces for each level. Strings and numbers stay exactly as typed.
- Base64 (RFC 4648) writes 3 bytes as 4 characters: 4 × ⌈n ÷ 3⌉ with = padding, or ⌈4n ÷ 3⌉ without padding (Base64url). That is about 33% more.
- Gzip is measured with the CompressionStream of your browser, when it has one. Another compressor or level gives a somewhat different size.
- Time to send = bytes × 8 ÷ bandwidth in bits per second.
Worked example
The example JSON order is 167 bytes as typed (166 characters: the é takes 2 bytes). Minified it is 123 bytes, 26.3% less; pretty with 2 spaces on every line it is 211 bytes. As Base64 it is 4 × ⌈167 ÷ 3⌉ = 224 characters.
A 250 kB image (250,000 bytes) sent inside JSON as Base64 takes 4 × ⌈250,000 ÷ 3⌉ = 333,336 bytes, 33.3% more. At 10 Mbit/s that is 0.267 seconds of transfer instead of 0.2.
Limits you should know
- The size on the wire also includes HTTP headers, and TLS and TCP add their own bytes. The time to send leaves out the round trip and the set-up of the connection.
- Servers often compress responses with gzip or Brotli at their own level, so the size you see in the browser network panel may differ from the gzip size here.
- Bodies of up to 2,000,000 characters can be measured. Nothing is uploaded.
- To format or check JSON, use the JSON Formatter & Validator. To encode text as Base64, use the Base64 Encoder & Decoder.