JSON Size Calculator

Whitespace Costs Bytes Over the Wire

The same JSON data can occupy noticeably different sizes depending purely on formatting — pretty-printed with indentation for human readability, minified with every unnecessary space stripped, or gzip-compressed for transmission. Knowing all three sizes for a given payload helps decide whether a response needs minification, compression, or both before it goes over the network.

The Formula

Size = UTF-8 encoded byte length of the JSON text

Byte length is measured after UTF-8 encoding rather than character count, since multi-byte characters (accented letters, emoji, non-Latin scripts) take up more than one byte each and would otherwise understate the actual payload size.

Worked Example

A small object with a nested array, in three formats
FormatSize
Pretty-printed (2-space indent)112 bytes
Minified (no whitespace)73 bytes
Gzip-compressed (minified)88 bytes

Minification alone saved roughly 35% here. Gzip compression on an already-small, low-repetition payload can actually add overhead rather than help — gzip's savings scale up with larger, more repetitive payloads, which is typical of real API responses with many similar records.

Where This Matters

  • API response optimization — comparing minified versus gzip-compressed size for a representative payload shows whether enabling compression on an endpoint is worth the CPU overhead.
  • Client-side storage limits — browser localStorage and similar storage APIs impose size caps, and checking a serialized object's byte size in advance avoids silent storage failures.
  • Debugging bloated payloads — if an API response seems unexpectedly large, comparing pretty-printed and minified sizes quickly shows how much is actual data versus formatting whitespace.

How to Use This Calculator

  1. Paste your JSON text into the input field.
  2. Select Calculate to see the original, minified, pretty-printed, and gzip-compressed byte sizes, along with the percentage saved by minification.

Related Calculations

Estimate how payload size affects page performance with the Page Load Time Calculator, or encode a payload for text-safe transmission with the Base64 Encoder/Decoder.