ThisCalculator

Everyday

JSON Payload Size Calculator: How to Measure It

Updated · Standard formula, shown below

The calculator for this page is switched off while it is checked. The formula is below, and the worked example in the article shows how to use it by hand.

JSON Payload Size Calculator: How to Measure It

This calculator works out the byte size of a JSON payload from its text, so you can see exactly how much space it takes up in storage or over the wire. You paste or type the JSON, and it returns the size in bytes, kilobytes, and megabytes. It also counts the number of characters, which is useful because some systems limit JSON by characters rather than bytes.

Formula

The core calculation is simple: the size of a JSON string in bytes equals the number of characters in the string, assuming every character is a single-byte ASCII character. The formulas used here are:

  • Bytes = number of characters in the JSON text (for ASCII)
  • Kilobytes = bytes ÷ 1,024
  • Megabytes = bytes ÷ 1,048,576

Where bytes is the count of characters, KB is kilobytes (1,024 bytes), and MB is megabytes (1,024 × 1,024 bytes). This calculator counts characters directly, so for pure ASCII JSON the byte count and character count are identical.

Worked Example

Using the default JSON text {"name":"Ada","age":36}:

  1. Count every character, including braces, quotes, colons, commas, and the space after the comma: {"name":"Ada","age":36} has 23 characters.
  2. Since all characters are ASCII (letters, digits, punctuation), bytes = 23.
  3. Kilobytes = 23 ÷ 1,024 = 0.022 KB.
  4. Megabytes = 23 ÷ 1,048,576 = 0.000022 MB.

The calculator shows 23 bytes, 23 characters, 0.022 KB, and 0.000022 MB, matching the manual calculation.

Why JSON Size Matters

JSON payload size is a practical concern in several everyday situations. APIs often have request or response size limits; a common limit is 1 MB, but some services cap at 100 KB or even smaller. If your JSON exceeds that, the request fails. Mobile apps sending JSON over cellular networks pay for every kilobyte, and large payloads make the app feel slow. Databases that store JSON documents (like PostgreSQL’s jsonb or MongoDB) consume storage proportional to the text size, and indexing large fields can slow down queries. Logging systems that capture JSON request bodies can fill up disk space quickly if payloads are large. Knowing the size before you deploy helps you decide whether to compress, trim fields, or paginate results.

How Character Encoding Affects Size

The most common misconception is that one character always equals one byte. That is only true for ASCII characters (A-Z, a-z, 0-9, punctuation, and control characters). JSON is defined as Unicode text, and when transmitted, it is typically encoded as UTF-8. In UTF-8:

  • ASCII characters (U+0000 to U+007F) use 1 byte each.
  • Latin-1 characters like é or ñ use 2 bytes.
  • Common CJK characters (Chinese, Japanese, Korean) use 3 bytes.
  • Emoji and rare symbols use 4 bytes.

So the JSON {"city":"München"} has 17 characters but 18 bytes, because the ü takes 2 bytes. If your JSON contains non-ASCII characters, the byte size will be larger than the character count. This calculator counts characters, so for non-ASCII input you should multiply the relevant characters by their UTF-8 byte length to get the true size. A quick rule: if your JSON is all plain English, character count equals byte count; if it contains accented letters, assume roughly 1.2–1.5× the character count; if it contains CJK text, assume 3× for those characters.

Common Mistakes When Estimating JSON Size

People frequently misjudge JSON size in a few predictable ways. The first is ignoring whitespace. Pretty-printed JSON with indentation and line breaks can be 20–50% larger than minified JSON. A 10 KB minified payload might become 14 KB when formatted. The second mistake is forgetting that numbers are stored as text. The number 123456789 takes 9 bytes, not 4 bytes like a binary integer. A large decimal like 3.141592653589793 takes 17 bytes. The third mistake is assuming that removing fields always shrinks the payload proportionally. Because JSON repeats keys, removing a field with a long key name saves more than just the value. The fourth mistake is confusing base-10 kilobytes (1,000 bytes) with base-2 kibibytes (1,024 bytes). Many API limits are stated in base-10, while storage systems often use base-2. Always check which convention the limit uses.

How to Reduce JSON Payload Size

If your JSON is too large, several standard techniques can shrink it without losing information. These are practical steps used in production systems:

  • Minify: remove all whitespace, line breaks, and indentation. This is the easiest win and often reduces size by 20–40%.
  • Shorten key names: replace "first_name" with "fn". This helps most when you have many objects with the same keys.
  • Use arrays instead of objects for repeated data: instead of [{"id":1,"v":10},{"id":2,"v":20}], use parallel arrays {"ids":[1,2],"vs":[10,20]}.
  • Remove null or default values: if a field is usually null, omit it entirely and let the receiver treat absence as null.
  • Round numbers: sending 3.14159 instead of 3.141592653589793 saves 8 bytes per value.
  • Consider gzip compression: JSON compresses extremely well, often to 10–20% of original size, especially when keys repeat. Most HTTP servers and clients support gzip transparently.

JSON vs. Other Formats for Size

JSON is not the most compact data format, but it is the most widely supported. Comparing typical serialized sizes for the same data:

  • JSON: readable, self-describing, but verbose due to repeated keys and quotes.
  • XML: usually 1.5–2× larger than JSON because of opening and closing tags.
  • CSV: often smaller than JSON for tabular data, but lacks nesting and type information.
  • MessagePack / BSON: binary formats that are typically 20–30% smaller than JSON and faster to parse, but not human-readable.
  • Protocol Buffers: the most compact of the common options, often 50–80% smaller than JSON, but requires a schema and code generation.

If payload size is critical and you control both ends of the connection, a binary format may be worth the complexity. If you need debuggability and universal support, JSON with gzip is a reasonable middle ground.

Limits of This Calculator

This calculator gives you the exact character count and the byte count for ASCII text. It does not parse the JSON to validate it—you can paste invalid JSON and it will still count the characters. It also does not account for UTF-8 multi-byte characters automatically, so if your JSON contains non-ASCII text, the byte count shown will be an underestimate. For a quick estimate of the true byte size with non-ASCII content, multiply the number of non-ASCII characters by 2 or 3 and add that to the ASCII count. The calculator also ignores any HTTP-level overhead like headers, which typically add a few hundred bytes to a request regardless of payload size.

Frequently Asked Questions

How many bytes is a JSON string? A JSON string is exactly the number of characters it contains, if all characters are ASCII. Each ASCII character is 1 byte. Non-ASCII characters take 2–4 bytes in UTF-8, so the byte count will be higher than the character count.

What is the maximum JSON payload size? There is no universal maximum. It depends entirely on the server, API, or storage system you are using. Common limits are 1 MB, 10 MB, or 100 KB. Check the documentation of the specific service you are calling. Some services have no explicit limit but will time out on very large payloads.

Does pretty-printed JSON take more space? Yes. Indentation, line breaks, and spaces between tokens are all characters. Minifying JSON removes these and can reduce size by 20–40% depending on how deeply nested the data is and how much indentation was used.

Is JSON size measured in bytes or characters? It depends on the context. HTTP Content-Length headers use bytes. Many programming languages report string length in characters. When a service says “max 1 MB”, it almost always means bytes. When a database field is defined as VARCHAR(1000), it may mean characters. Always check which unit the limit uses.

Can gzip make JSON smaller? Yes, dramatically. JSON is highly repetitive—key names appear in every object—so gzip often compresses it to 10–20% of its original size. Many web servers automatically gzip JSON responses, and most HTTP clients decompress them transparently. If you control the server, enabling gzip is the single most effective way to reduce JSON transfer size.

Why does my JSON size change after I save it to a file? Text editors may add a trailing newline, change line endings (Windows uses \r\n which is 2 bytes vs. Unix \n which is 1 byte), or convert to a different encoding like UTF-16 which doubles the size of ASCII characters. Check your editor’s encoding and line-ending settings if file size matters.

Related

Formula used
in t | JSON text | - | {"name":"Ada","age":36} | 0
out bytes | Size in bytes | bytes | (len(t)) | 0
out chars | Character count | chars | (len(t)) | 0
out kb | Size in kilobytes | KB | (len(t)) / 1024 | 3
out mb | Size in megabytes | MB | (len(t)) / (1024*1024) | 6

Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.